Docker – none 컨테이너 삭제하기

$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vpsdemop            latest              12473ad26899        2 minutes ago       1GB
<none>              <none>              84a6c05698e4        2 minutes ago       1GB
<none>              <none>              4011590a442e        3 minutes ago       1GB
<none>              <none>              fdf69123da65        3 minutes ago       1GB
...
<none>              <none>              b4a359727bd7        7 hours ago         112MB
ubuntu              20.04               1d622ef86b13        5 weeks ago         73.9MB
ubuntu              latest              1d622ef86b13        5 weeks ago         73.9MB

$ docker system prune
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all dangling build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
8df4735033ad6cedf4a3231368a99ab4e2121d717f6d025bf2773ff6c755e197
e923e2b8076739edbb33c6d5bb9864346d0ba6b7882df148bcc831f65cc9db98
...
deleted: sha256:97ee249f1d92e909be67962aaab947390273413854f6d710b0fb279e1917b36a
deleted: sha256:8b4f5330ef79a9b5b369a9168d45a49604d02761229edf60e1aa125cf4030530

Total reclaimed space: 5.38GB

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vpsdemop            latest              12473ad26899        3 minutes ago       1GB
ubuntu              20.04               1d622ef86b13        5 weeks ago         73.9MB
ubuntu              latest              1d622ef86b13        5 weeks ago         73.9MB

CentOS 7에 특정 버전의 Docker-CE 설치하기

$ yum remove docker docker-client docker-client-latest docker-common docker-latest                   docker-latest-logrotate docker-logrotate docker-engine
$ rm -rf /var/lib/docker/

$ sudo yum install -y yum-utils

$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ yum list docker-ce --showduplicates | sort -r
...
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
...

$ yum install docker-ce-18.09.9 docker-ce-cli-18.09.9

$ docker --version
Docker version 18.09.9, build 039a7df9ba

$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

$ systemctl start docker
$ systemctl status docker

Ubuntu 12.04 에 Python 3.7 설치하기

사실 python 에서 protobuf3 를 사용할려면..
최신의 protobuf3 버전이 현재 python 3.7용만 설치가 되는듯하다..
기본 Ubuntu 12.04는 python이.. 3.8..

암튼.. python 3.7을 설치하려면 아래와 같이 하면됨.

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt install python3.7
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python3.7 get-pip.py

$ vim ~/.bashrc
alias pip='/home/ihmin/.local/bin/pip3.7'
alias python='/usr/bin/python3.7'

$ python --version
Python 3.7.7

$ pip --version
pip 20.1.1 from /home/ihmin/.local/lib/python3.7/site-packages/pip (python 3.7)

pip로 설치된 package는 아래에 설치됨.

/home/ihmin/.local/lib/python3.7/site-packages

CentOS 6 gcc 버전 업데이트

$ yum install centos-release-scl-rh centos-release-scl
$ yum check-update
$ yum install devtoolset-7-gcc-c++
$ source /opt/rh/devtoolset-7/enable
$ gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

아래도 가능..

yum install devtoolset-7-gcc-c++ (GCC 7.3.1)
yum install devtoolset-8-gcc-c++ (GCC 8.3.1)
yum install devtoolset-9-gcc-c++ (GCC 9.1.1)

아래와 같이 devtoolset-7-gcc-c++ 을 enable..

$ vim /etc/profile.d/enabledevtoolset-7.sh
#!/bin/bash
source /opt/rh/devtoolset-7/enable

Docker Engine 설치

참고: https://docs.docker.com/install/linux/docker-ce/centos/

요즘 핫한.. (요즘 이라기엔.. 2013년도에 처음 나온 기술이라..) CentOS 7 에서 docker engine 을 설치해봄. 아래는 sudo 를 통하지않고 root 계정에서 직접 설치.

$ uname -a
Linux xxx 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

CentOS를 최신으로 업데이트함.

$ yum update

기존 docker engine이 설치되어 있을경우 최신 버전의 docker engine을 설치하기위해 삭제함.

$ yum remove docker docker-client docker-client-latest docker-common docker-latest 
 docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

docker engine을 설치하는데 필요한 종속 프로그램 설치. 이미 최신 버전이 설치되어 있을수 있음

$ yum install -y yum-utils device-mapper-persistent-data lvm2

docker engine 공식 repository 추가

$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

설치가능한 docker engine 버전 확인.. ce는 Community Edition 인데 무료버전임.

$ yum list docker-ce --showduplicates | sort -r
....
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
.....
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
....
....
 * base: mirror.kakao.com
Available Packages

docker engine 최신 버전 설치

$ yum install docker-ce
....
---> Package container-selinux.noarch 2:2.107-1.el7_6 will be installed
---> Package containerd.io.x86_64 0:1.2.6-3.3.el7 will be installed
---> Package docker-ce-cli.x86_64 1:19.03.2-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================
 Package                         Arch                 Version                          Repository                      Size
==================================
Installing:
 docker-ce                       x86_64               3:19.03.2-3.el7                  docker-ce-stable                24 M
Installing for dependencies:
 container-selinux               noarch               2:2.107-1.el7_6                  extras                          39 k
 containerd.io                   x86_64               1.2.6-3.3.el7                    docker-ce-stable                26 M
 docker-ce-cli                   x86_64               1:19.03.2-3.el7                  docker-ce-stable                39 M

Transaction Summary
==================================
Install  1 Package (+3 Dependent packages)

Total download size: 90 M
Installed size: 368 M
Is this ok [y/d/N]: 

y눌러서 설치… 조금 기다리면 아래와 같이 설치가 완료됨.

Running transaction
  Installing : 2:container-selinux-2.107-1.el7_6.noarch  1/4 
  Installing : containerd.io-1.2.6-3.3.el7.x86_64        2/4 
  Installing : 1:docker-ce-cli-19.03.2-3.el7.x86_64      3/4 
  Installing : 3:docker-ce-19.03.2-3.el7.x86_64          4/4 
  Verifying  : 3:docker-ce-19.03.2-3.el7.x86_64          1/4 
  Verifying  : containerd.io-1.2.6-3.3.el7.x86_64        2/4 
  Verifying  : 2:container-selinux-2.107-1.el7_6.noarch  3/4 
  Verifying  : 1:docker-ce-cli-19.03.2-3.el7.x86_64      4/4 

Installed:
  docker-ce.x86_64 3:19.03.2-3.el7                                                                                          

Dependency Installed:
  container-selinux.noarch 2:2.107-1.el7_6   containerd.io.x86_64 0:1.2.6-3.3.el7   docker-ce-cli.x86_64 1:19.03.2-3.el7  

Complete!

참고로 특정 버전의 docker engine을 설치하고자 한다면 아래와 같이..

$ yum install docker-ce-18.09.0

자 이제.. docker engine 서비스를 실행하고..

$ systemctl start docker

다음 docker version 을 확인함.

$ docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:28:55 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:27:34 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

“hello world” docker 이미지 설치

$ docker run hello-world
Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
....
For more examples and ideas, visit:
 https://docs.docker.com/get-started/

설치된 이미지 확인..

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        8 months ago        1.84kB

CentOS 부팅시 docker engine 서비스가 자동으로 실행되게 하면 좋음.

$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

이로써 CentOS 7 에서 docker engine을 설치완료. 굿!!

참고로 난 docker engine 을 root 계정에서 설치를 했는데..
일반 유저 계정에서 실행하려니.. 아래와 같이 에러가 발생..

$ docker version
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix /var/run/docker.sock: connect: permission denied

이런 경우 아래와 같이 해결. 만약 유저 계정 id가 ihmin 이라면..

$ usermod -a -G docker ihmin
$ service docker restart

다음 완전히 로그아웃한다음 다시 로그인하면 잘됨..

CentOS 6 에서 php 5.6으로 업그레이드하기

dokuwiki 를 설치하는데 install.php 가 505 에러가 뜨면서 안된다..
확인해보니.. php 버전이 낮더라..
기본 CentOS 6 에는 php 5.3.3이 깔려있음.

# lsb_release -a
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.9 (Final)
Release:	6.9
Codename:	Final

# php -v
PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[root@olddos-bbs html]# yum --enablerepo=remi-php56 install php
Loaded plugins: fastestmirror, refresh-packagekit, security

아래와 같이 업그레이드..

# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
# yum remove php-common php php-gd php-xml
# yum install -y php56w php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
# service httpd restart

단 yum install 중에.. 아래와 같이 에러가 뜨면..

Error: php56w-common conflicts with php-common-5.3.3-49.el6.x86_64
Error: Package: libmcrypt-2.5.8-13.el7.x86_64 (epel)
           Requires: libc.so.6(GLIBC_2.14)(64bit)

php56w-mcrypt 빼고 설치할것.

get keyboard inputs without blocking

블럭킹없이 키보드 입력 받는 코드..

#include <ros/ros.h>
#include <termios.h>

char getch()
{
	fd_set set;
	struct timeval timeout;
	int rv;
	char buff = 0;
	int len = 1;
	int filedesc = 0;
	FD_ZERO(&set);
	FD_SET(filedesc, &set);
	
	timeout.tv_sec = 0;
	timeout.tv_usec = 1000;

	rv = select(filedesc + 1, &set, NULL, NULL, &timeout);

	struct termios old = {0};
	if (tcgetattr(filedesc, &old) < 0)
		ROS_ERROR("tcsetattr()");
	old.c_lflag &= ~ICANON;
	old.c_lflag &= ~ECHO;
	old.c_cc[VMIN] = 1;
	old.c_cc[VTIME] = 0;
	if (tcsetattr(filedesc, TCSANOW, &old) < 0)
		ROS_ERROR("tcsetattr ICANON");

	if(rv == -1)
		ROS_ERROR("select");
	else if(rv == 0)
		ROS_INFO("no_key_pressed");
	else
		read(filedesc, &buff, len );

	old.c_lflag |= ICANON;
	old.c_lflag |= ECHO;
	if (tcsetattr(filedesc, TCSADRAIN, &old) < 0)
		ROS_ERROR ("tcsetattr ~ICANON");
	return (buff);
}


int main(int argc, char **argv)
{
	ros::init(argc, argv, "key_input_node");
	ros::NodeHandle n;

	ros::Rate loop_rate(10);
	while (ros::ok())
	{
		int c = 0;
		c=getch();
		ROS_INFO("%c", c);

		ros::spinOnce();

		loop_rate.sleep();
	}

	return 0;
}

CentOS 에서 USB 하드 마운트 시키기

우선 USB 하드를 꼽고, fdisk -l을 입력함.

% fdisk -l
...
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x03f92b08

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1      121602   976762528    7  HPFS/NTFS
...

다음 마운트해본다.

% mount /dev/sdb1 /home/usb
mount: unknown filesystem type

ntfs 파일 시스템을 인식못함.

% yum install -y yum-priorities 
% vim /etc/yum/pluginconf.d/priorities.conf
[main]
enabled = 1
check_obsoletes = 1 <-- 추가
priority = 2 <-- 추가

다음 아래 싸이트에 가서 내 시스템에 맞는 rpm을 설치한다.
http://pkgs.repoforge.org/rpmforge-release/

% rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
% yum check-update
% yum install fuse fuse-ntfs-3g dkms dkms-fuse

이제 마운트해본다.

% mount /dev/sdb1 /home/usb