Docker

Install

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
$ apt-cache policy docker-ce
$ sudo apt install docker-ce
$ sudo usermod -aG docker ${USER}
$ su - ${USER}
$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo \\n  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \\n  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
$ systemctl docker status
$ sudo service docker status
$ sudo usermod -aG docker $USER
$ sudo docker images

Image : Start

설치 및 운영이

 docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:5b3cc85e16e3058003c13b7821318369dad01dac3dbb877aac3c28182255c724
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

도커가 실행되기 전 까지는 Images 이름을 사용하여 도커를 실행한다

$ docker pull whitelok/watermark-remover:v1.0
$ docker images                          
REPOSITORY           TAG   IMAGE ID       CREATED       SIZE
whitelok/watermark   v1.0  3f8b40e85ef4   2 years ago   5.52GB

$ docker container run -d -t -p 9000:8090 3f8b40e85ef4               
8ad57f47e456d14f2756268f08b871f0e786a3179714b8de603356a6bca724f8

$ docker ps                                           
CONTAINER ID   IMAGE          COMMAND     CREATED   STATUS
8ad57f47e456   3f8b40e85ef4   "python3"   3se ago   0.0.0.0:9000->8090

Id : Process & Stop

  • https://itholic.github.io/docker-copy/

도커가 실행된 이후에는 ID 를 사용하여, 스크립트 실행, 파일복사, 중단을 명령한다

$ docker exec -it 8ad57f47e456  /bin/bash
root@8ad57f47e456:~/watermark-remover#

$ docker cp priceless_heyrovsky:/root/watermark-remover/demo  ./
$ docker cp ./png priceless_heyrovsky:/root/watermark-remover/demo/

$ docker stop 8ad57f47e456
$ docker system prune -a