docker에 대해 알아보던 중 docker를 이미지로 설치할 때 우분투 환경에서만 링크로 설정하여야 한다는 것을 보게되었다.


왜 그런지 알아보던 중 한 분이 해당 url을 알려주셨다. 


ubuntu 패키지에는 이미 그래픽환경을 위한 system tray로 docker라는 것이 존재한다. (새삼 깨달았다.. 그 이름이 docker라는 걸..)


이것과의 혼동을 피하기 위해 docker.io 형태로 지원을 한다. 이것을 사용하려면 링크를 걸어줘야 한다.



해당 url은 Docker가 무엇인지 대략적으로 간단하게 설명하고 있다.

https://www.maketecheasier.com/running-docker-io-under-ubuntu-linux/




Running Docker.io Under Ubuntu Linux


우분투 리눅스에서 Docker.io 실행





As powerful hardware has become more and more of a commodity, the ability to run multiple virtual machines on a single piece of hardware has become an industry norm. From web hosting to cloud computing, many services are run on virtualized environments. As well as desktop virtualization solutions like VirtualBox, there are also quick provisioning solutions like Vagrant. The problem with a virtual machine is that it needs to emulate every aspect of the guest computer including all the system RAM which will be allocated exclusively to the virtual machine. As a result, virtualization can be resource hungry.

파워풀한 하드웨어가 상품화 되어지면서, 하나의 하드웨어에서 여러 virtual machines을 실행하는 능력은 업계의 표준이 되었다.

클라우드 컴퓨팅을 위한 웹 호스팅으로 부터, 많은 서비스들은 가상 환경에서 동작한다.

VirtualBox같은 가상화 솔루션을 더불어 Vagrant와 같은 빠른 프로비저닝 솔루션 또한 있다.

가상머신의 문제는 오직 가상머신을 위해 할당 될 모든 시스템 메모리를 포함하여 게스트 컴퓨터의 모든 측면을 에뮬레이트 해야할 필요가 있다는 것이다. 결과적으로 가상화는 자원부족이 될 수 있다.



At the other end of the spectrum is a “chroot” environment, which changes the underlying root directory for a process so that it runs in its own environment and has no access to other files on the host operating system. However, there is no virtualization at all, just a different directory tree.

극단적으로??, 프로세스를 위해 원래의 root directory를 바꾸며 자신의 환경에서 실행되고 호스트 OS상의 다른 파일에게 액세스하지 않는 "chroot" 환경이다. 하지만 이것은 가상환경이 아니며 단지 다른 device tree일 뿐이라는 것이다.



The mid-point between these two systems is a container. Containers offer many of the advantages of a virtualized machine but without the high resource overhead. Containers are more functional than chroot environments in that there is some virtualization. For example, processes that are created in a container are assigned IDs (PIDs) separately from those in the host OS. In technical terms, the container has its own PID namespace. In fact, containers have their own namespace for the networking subsystem and for InterProcess Communication (IPC). That means that a container can run network services, like a SSH server or a web server.

이 두 시스템 사이에서의 중간 포인트는 컨테이너이다. 컨테이너는 많은 자원의 오버헤드 없이 가상화된 머신에서 많은 어드밴티지를 제공한다. 컨테이너는 가상화 환경에서 chroot 환경보다 더 functional하다. 예를들어 컨테이너 기술로 생성된 프로세스들은 Host OS로부터 각각 PIDs를 가진다. 즉 컨테이너는 그들 자신의 PID namespace를 갖는다. 사실 컨테이너는 네트워킹 서브시스템과 IPC를 위해 스스로의 namespace를 갖고있다. 이 말은 컨테이너는 SSH 서비스나 web server 같은 네트워크 서비스를 수행할 수 있다는 의미이다.



From the outside, the container looks like a virtual machine with its own IP address and its own networking services, but on the inside the container uses much more of the host operating system than a virtual machine, more like a “chroot” environment. For example, you can use a CentOS container running on a Ubuntu host. The commands and files are all from CentOS, but if you ask the container which kernel it is running, it will report it is running the Ubuntu kernel, because the container is running on the kernel from the host OS.

외부로부터, 컨테이너는 자신만의 IP address와 자신만의 네트워크 서비스들을 갖는 가상머신처럼 보이지만 컨테이너 내부에서는 가상머신보다 "chroot"환경에 더 가까운 host OS를 사용한다. 예를들어 Ubuntu host 위에서 CentOS 컨테이너를 동작시킬 수 있다. 모든 명령과 파일들은 CentOS 기반으로 동작하지만 만약 컨테이너에게 실행중인 커널을 물어본다면 컨테이너는 Host OS의 커널에서 동작하므로 Ubuntu 커널에서 동작하고 있음을 알릴 것이다. 



Docker is a container based virtualization framework that allows you to create containers holding all the dependencies for an application. Each container is kept isolated from any other, and nothing gets shared.

Docker는 가상 framwork 기반의 컨테이너 기술로 application을 위한 모든 dependencies에 대해 홀딩상태의 컨테이너를 생성할 수 있다. 각각의 컨테이너는 독립을 유지하며 공유를 하지 않는다. 



To install Docker on a 64-bit Ubuntu 14.04 system, run the following commands:

Ubuntu 14.04 시스템 기반에서 Docker를 설치하기 위해서는 다음 명령어를 수행한다.






There is an existing Ubuntu package called docker, which is a system tray for KDE3/GNOME2. To avoid confusion, the container runtime is called docker.io. The last command creates a link from “/usr/local/bin/docker” to “/usr/bin/docker.io”, which enables the docker command from the command line rather than docker.io.

Ubuntu 패키지에는 "docker"라고 불리는 KDE3/GNOME2를 위한 시스템 트레이가 있다. 혼란을 피하기 위해 컨테이너 실행시간은 docker.io라고 불린다. 마지막 명령에서는 “/usr/local/bin/docker”로부터 “/usr/bin/docker.io”에게 링크를 생성하며, 이것은 docker.io 대신 커맨드라인으로 docker 명령의 수행을 가능하게 한다.



Note: Docker.io is also available for other distro. Here is the installation instructions if you are not using Ubuntu.

Docker.io는 다른 리눅스 배포판에서도 사용할 수 있다. 만약 Ubuntu를 사용하지 않는 다면 여기 설치 명령이 있다.



To execute a shell inside the container, run:

container에서 shell을 실행하기, "run" :





The “-i” flag makes the session interactive, and the “-t” flag tells docker to emulate a terminal session. The “ubuntu” parameter tells docker to run a container based on Ubuntu 14.04 and “/bin/bash” is the command that should be run once the container is up, i.e. run the Bash shell.

"-i" 플래그는 session 상호작용을 만들고, "-t" 플래그는 docker에게 terminal session을 에뮬레이트하라고 한다. "ubuntu"는  Ubuntu 14.04 기반으로 container를 수행하라는 파라미터이며, "/bin/bash"는 컨테이너가 뜰 때 수행할 필요가 있는 명령이다. 즉, Bash shell을 실행한다. 



When docker runs it checks if the desired base image file has been previously downloaded. If it hasn’t, it will download the image from index.docker.io, which is also the site to use to see which images are officially supported by docker.

docker가 run 할때, 만약 원했던 base image 파일이 이미 다운되어져 있다면 확인한다. 만약 다운되어있는 base image 파일이 없다면 docker로 부터 공식적으로 지원되는 이미지를 사용하고 볼 수 있는 사이트인 index.docker.io에서 이미지를 다운로드 할 것이다. 



To download other images without starting a container, use the “docker pull” command. For example, to download the CentOS base image use:

컨테이너의 사작없이 다른 이미지를 다운로드 하려면 "docker pull" 명령을 사용하면 된다. 예를들어, CentOS base image 다운로드는 다음과 같다.





You can also run single commands in a container and then let the container exit. Use the following command to run the “ps aux” command inside the CentOS container:

또한 컨테이너에서 하나의 명령을 실행한 다음 컨테이너를 종료할 수 있다. 실행을 위한 명령은 CentOS 컨테이너 내부의 "ps aux"를 사용한다. 





When a container shuts down, all changes are lost. The advantage of this approach is that when a container starts, it is in a known state. This is essential for test environments and for build services, etc. It is also important for running cloud services, as the container can be quickly reset and rebooted into a stable state.

컨테이너가 shutdown 될 때, 모든 변경사항은 지워진다. 이것의 장점은 컨테이너가 시작할 때의 알려진 상태에 있다는 것이다. 이것은 테스트환경과 서비스 빌드와 기타 등등에 필수적인 것이다. 또한 컨테이너가 안정된 상태의 빠른 reset과 reboot 을 할 수 있는 것과 같의 클라우드 서비스의 실행을 위해 중요하다. 



However, it also means that any configuration performed or any files created in the container will be lost. The solution is to create a new image with all your changes. Try the following commands:

하지만 이것은 컨테이너에서 설정한 구성과 생성된 파일들의 손실될 것을 의미한다. 해결방법은 모든 변경사항에 대해 새로운 이미지를 생성하는 것이다. 다음의 명령어이다. 





The first command will start a container and install nmap. The second command will list the latest (-l) created container, even if it isn’t running.

첫번째 명령은 컨테이너를 실행하고 nmap을 설치할 것이다.

두번째 명령은 명령이 실행되지 않더라도 최신의 생성된 컨테이너 순으로 리스트업 할 것이다.





You can now create a snapshot of that container and save it to a new image:

이제 새로운 이미지를 위해 컨테이너를 스냅샷을 생성하고 저장할 수 있다. 





“1b498c2d502c” is the ID of the container as listed by the “docker ps -l” command. Now if you start a shell for the ubuntu-with-nmap container, it will have the nmap command pre-installed.

“1b498c2d502c”는 "docker ps -l" 명령어에 의해 리스트업 될 컨테이너의 ID이다. 이제 ubuntu-with-nmap 컨테이너를 위해 shell을 시작하려면, 설치 전 nmap 명령을 수행해야 한다.






There is plenty of information about docker in docker.io’s documentation, and there are also several example setups explained, including how to perform common tasks like running a python web app and running a SSH service.

docker.io's documentation에 docker에 대한 많은 정보가 있으며 설치를 설명하는 몇가지 예제와 python web app과 SSH 서비스 실행과 같은 작업을 수행하는 방법이 나와있다.


If you have any questions about docker, there is a strong docker community which should be able to help. You can also ask questions in the comment section below and we will see if we can help.

만약 docker에 대해 질문이 있다면 docker community를 이용할 수 있다. 해당 글에대한 질문은 아래에  comment를 남겨주면 우리가 보고 도움을 주겠다.




+ Recent posts