관리자 전환
sudo -i
Ruby
복사
도커설치
apt install doker.io
Ruby
복사
업데이트 때문에 문제가 발생하면
reboot를 눌러서해결
Ruby
복사
톰켓검사
doker search tomcat
Ruby
복사
톰켓 시작 tc는 그냥 이름
docker run -d -p 8080:8080 --name tc consol/tomcat-7.0
Ruby
복사
주소창에 127.0.0.1:8080
도커 명령어로 검색
sudo docker search tomcat
Ruby
복사
MySQL Pull 하기
docker pull mysql
Ruby
복사
가지고 있는 이미지를 확인하는 명령어
docker images
Ruby
복사
실습 log
server1@server1-VirtualBox:~$ sudo -i
[sudo] server1의 암호:
root@server1-VirtualBox:~# apt install docker.io
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
패키지 docker.io는 이미 최신 버전입니다 (20.10.2-0ubuntu1~18.04.2).
0개 업그레이드, 0개 새로 설치, 0개 제거 및 513개 업그레이드 안 함.
root@server1-VirtualBox:~# docker tomcat
docker: 'tomcat' is not a docker command.
See 'docker --help'
root@server1-VirtualBox:~# docker searchtomcat
docker: 'searchtomcat' is not a docker command.
See 'docker --help'
root@server1-VirtualBox:~# docker search tomcat
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 3070 [OK]
tomee Apache TomEE is an all-Apache Java EE certif… 91 [OK]
dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base… 57 [OK]
consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 18 [OK]
cloudesire/tomcat Tomcat server, 6/7/8 15 [OK]
aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL 13 [OK]
arm32v7/tomcat Apache Tomcat is an open source implementati… 11
andreptb/tomcat Debian Jessie based image with Apache Tomcat… 10 [OK]
maluuba/tomcat7-java8 Tomcat7 with java8. 6
rightctrl/tomcat CentOS , Oracle Java, tomcat application ssl… 6 [OK]
unidata/tomcat-docker Security-hardened Tomcat Docker container. 5 [OK]
arm64v8/tomcat Apache Tomcat is an open source implementati… 3
amd64/tomcat Apache Tomcat is an open source implementati… 3
jelastic/tomcat An image of the Tomcat Java application serv… 2
cfje/tomcat-resource Tomcat Concourse Resource 2
oobsri/tomcat8 Testing CI Jobs with different names. 2
fabric8/tomcat-8 Fabric8 Tomcat 8 Image 2 [OK]
camptocamp/tomcat-logback Docker image for tomcat with logback integra… 1 [OK]
picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAGER… 1 [OK]
ppc64le/tomcat Apache Tomcat is an open source implementati… 1
chenyufeng/tomcat-centos tomcat基于centos6的镜像 1 [OK]
99taxis/tomcat7 Tomcat7 1 [OK]
s390x/tomcat Apache Tomcat is an open source implementati… 0
softwareplant/tomcat Tomcat images for jira-cloud testing 0 [OK]
secoresearch/tomcat-varnish Tomcat and Varnish 5.0 0 [OK]
root@server1-VirtualBox:~# docker run -d -p 8080:8080 --name consol/tomcat-7.0
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
root@server1-VirtualBox:~# docker run -d -p 8080:8080 --name tc consol/tomcat-7.0
Unable to find image 'consol/tomcat-7.0:latest' locally
latest: Pulling from consol/tomcat-7.0
Image docker.io/consol/tomcat-7.0:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
e5ad7970bc69: Pull complete
a3ed95caeb02: Pull complete
d1bc08d19aa0: Pull complete
e4b877670a03: Pull complete
7fe52da169a9: Pull complete
dd8c3151a5a5: Pull complete
70eb33b1a032: Pull complete
878a118528b8: Pull complete
1c0747c147d5: Pull complete
0d0d0f226ce8: Pull complete
56357e7ea3fa: Pull complete
3c3554f7c62d: Pull complete
23de17079739: Pull complete
Digest: sha256:8256b5e8e01fc4f6c1913e1fd70dea95ae656400f70fb1c12157d0e89e1ccaf7
Status: Downloaded newer image for consol/tomcat-7.0:latest
9e15e9a94ecc213fddfb57afd3bce1f791255e1de80b852c155096d5f841e8fe
root@server1-VirtualBox:~# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
b4d181a07f80: Pull complete
a462b60610f5: Pull complete
578fafb77ab8: Pull complete
524046006037: Pull complete
d0cbe54c8855: Pull complete
aa18e05cc46d: Pull complete
32ca814c833f: Pull complete
9ecc8abdb7f5: Pull complete
ad042b682e0f: Pull complete
71d327c6bb78: Pull complete
165d1d10a3fa: Pull complete
2f40c47d0626: Pull complete
Digest: sha256:52b8406e4c32b8cf0557f1b74517e14c5393aff5cf0384eff62d9e81f4985d4b
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
root@server1-VirtualBox:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 5c62e459e087 3 weeks ago 556MB
consol/tomcat-7.0 latest 7c34bafd1150 6 years ago 601MB
Ruby
복사
도커 이미지 다운로드하기
sudo docker pull tomcat
JavaScript
복사
로컬 시스템에 있는 도커 이미지 확인하기
sudo docker images
JavaScript
복사
도커 이미지 다운로드와 삭제
sudo docker pull consol/tomcat-7.0
sudo docker rmi consol/tomcat-7.0
Bash
복사
톰캣 컨테이너 생성
sudo docker run -d --name tc tomcat # 톰캣 생성 및 실행
Bash
복사
실행중인 컨테이너 확인
sudo docker ps # 톰캣 컨테이너 확인
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6e513b399a6 tomcat "catalina.sh run" 27 seconds ago Up 26 seconds 8080/tcp tc
Bash
복사
모든 컨테이너 확인
sudo docker ps -a # 모든 컨테이너 확인
Bash
복사
컨테이너 중지
sudo docker stop f6e513b399a6 # 컨테이너 실행 중지
f6e513b399a6
Bash
복사
컨테이너 삭제
sudo docker rm f6e513b399a6 # 컨테이너 삭제
f6e513b399a6
Bash
복사
nginx 설치
docker create -d nginx
Ruby
복사
nginx 컨테이너를 이름 변경하기
root@server1-VirtualBox:~# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
b4d181a07f80: Already exists
66b1c490df3f: Pull complete
d0f91ae9b44c: Pull complete
baf987068537: Pull complete
6bbc76cbebeb: Pull complete
32b766478bc2: Pull complete
Digest: sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
root@server1-VirtualBox:~# docker create -d nginx
unknown shorthand flag: 'd' in -d
See 'docker create --help'.
root@server1-VirtualBox:~# docker create -p 80:80 nginx
15f832be5ce1e43ec713ad1b33e2263d0c640d63bee17184047609f33b369249
root@server1-VirtualBox:~# docker create -p 80:80 --name nginx
"docker create" requires at least 1 argument.
See 'docker create --help'.
Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Create a new container
root@server1-VirtualBox:~# docker create -p 80:80 --name nginx
"docker create" requires at least 1 argument.
See 'docker create --help'.
Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Create a new container
root@server1-VirtualBox:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
15f832be5ce1 nginx "/docker-entrypoint.…" 27 seconds ago Created distracted_pascal
9e15e9a94ecc consol/tomcat-7.0 "/bin/sh -c /opt/tom…" 14 hours ago Up 14 hours 0.0.0.0:8080->8080/tcp, 8778/tcp tc
root@server1-VirtualBox:~# docker start -d ^C
root@server1-VirtualBox:~# ^C
root@server1-VirtualBox:~# docker start -d 15f832be5ce1
unknown shorthand flag: 'd' in -d
See 'docker start --help'.
root@server1-VirtualBox:~# docker start -d 15f832be5ce1
unknown shorthand flag: 'd' in -d
See 'docker start --help'.
root@server1-VirtualBox:~# docker start d 15f832be5ce1
Error response from daemon: No such container: d
15f832be5ce1
Error: failed to start containers: d
root@server1-VirtualBox:~# docker start -d 15f832be5ce1
unknown shorthand flag: 'd' in -d
See 'docker start --help'.
root@server1-VirtualBox:~# docker start 15f832be5ce1
15f832be5ce1
root@server1-VirtualBox:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
15f832be5ce1 nginx "/docker-entrypoint.…" 2 minutes ago Up 38 seconds 0.0.0.0:80->80/tcp distracted_pascal
9e15e9a94ecc consol/tomcat-7.0 "/bin/sh -c /opt/tom…" 14 hours ago Up 14 hours 0.0.0.0:8080->8080/tcp, 8778/tcp tc
root@server1-VirtualBox:~# docker run -d -p 88:80 --name nx nginx
0505aa65bc6de6ecd6f62b28743df2bc47b7ba524a84266439259c5935e9b127
root@server1-VirtualBox:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0505aa65bc6d nginx "/docker-entrypoint.…" 10 seconds ago Up 9 seconds 0.0.0.0:88->80/tcp nx
15f832be5ce1 nginx "/docker-entrypoint.…" 12 minutes ago Up 10 minutes 0.0.0.0:80->80/tcp distracted_pascal
9e15e9a94ecc consol/tomcat-7.0 "/bin/sh -c /opt/tom…" 15 hours ago Up 15 hours 0.0.0.0:8080->8080/tcp, 8778/tcp tc
root@server1-VirtualBox:~#
Ruby
복사
docker 콘테이너를 start 하기 (일련번호로 실행)
docker start 15f832be5ce1
Ruby
복사
아래의 명령어를 보면 실행중인 docker 콘테이너 리스트를 확인이 가능하다.
root@server1-VirtualBox:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0505aa65bc6d nginx "/docker-entrypoint.…" 4 minutes ago Up 4 minutes 0.0.0.0:88->80/tcp nx
15f832be5ce1 nginx "/docker-entrypoint.…" 17 minutes ago Up 15 minutes 0.0.0.0:80->80/tcp distracted_pascal
9e15e9a94ecc consol/tomcat-7.0 "/bin/sh -c /opt/tom…" 15 hours ago Up 15 hours 0.0.0.0:8080->8080/tcp, 8778/tcp tc
root@server1-VirtualBox:~#
Ruby
복사
컨테이너 삭제(실행중이지 않는건 바로 삭제 가능)
root@server1-VirtualBox:~# docker stop 15f832be5ce1
15f832be5ce1
root@server1-VirtualBox:~# docker rm 15f832be5ce1
15f832be5ce1
root@server1-VirtualBox:~#
Ruby
복사
docker Image 확인후 삭제하기
root@server1-VirtualBox:~# docker rmi nginx
Error response from daemon: conflict: unable to remove repository reference "nginx" (must force) - container 0505aa65bc6d is using its referenced image 4cdc5dd7eaad
root@server1-VirtualBox:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0505aa65bc6d nginx "/docker-entrypoint.…" 9 minutes ago Up 9 minutes 0.0.0.0:88->80/tcp nx
9e15e9a94ecc consol/tomcat-7.0 "/bin/sh -c /opt/tom…" 15 hours ago Up 15 hours 0.0.0.0:8080->8080/tcp, 8778/tcp tc
root@server1-VirtualBox:~# docker stop nginx
Error response from daemon: No such container: nginx
root@server1-VirtualBox:~# docker stop nx
nx
root@server1-VirtualBox:~# docker rmi nginx
Error response from daemon: conflict: unable to remove repository reference "nginx" (must force) - container 0505aa65bc6d is using its referenced image 4cdc5dd7eaad
root@server1-VirtualBox:~# docker rm nx
nx
root@server1-VirtualBox:~# docker rmi nginx
Untagged: nginx:latest
Untagged: nginx@sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9
Deleted: sha256:4cdc5dd7eaadff5080649e8d0014f2f8d36d4ddf2eff2fdf577dd13da85c5d2f
Deleted: sha256:63d268dd303e176ba45c810247966ff8d1cb9a5bce4a404584087ec01c63de15
Deleted: sha256:b27eb5bbca70862681631b492735bac31d3c1c558c774aca9c0e36f1b50ba915
Deleted: sha256:435c6dad68b58885ad437e5f35f53e071213134eb9e4932b445eac7b39170700
Deleted: sha256:bdf28aff423adfe7c6cb938eced2f19a32efa9fa3922a3c5ddce584b139dc864
Deleted: sha256:2c78bcd3187437a7a5d9d8dbf555b3574ba7d143c1852860f9df0a46d5df056a
root@server1-VirtualBox:~#
Ruby
복사