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

도커가 실행되기 전 까지는 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