Docker
7/2-2 이미지 제작 및 업로드, Dockerfile
- -
도커허브 계정이 있으면 계정명 붙여줘야함.
vagrant@docker:~$ docker tag hello-world:latest hms06/hello:v1 vagrant@docker:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE wordpress 5.7.2 7e372e91d00b 33 hours ago 551MB wordpress latest 7e372e91d00b 33 hours ago 551MB haproxy 2.4.1 0d8843c089fb 6 days ago 95.4MB mysql 5.7 09361feeb475 8 days ago 447MB httpd latest 30287d899656 8 days ago 138MB debian latest 7a4951775d15 9 days ago 114MB ubuntu latest 9873176a8ff5 2 weeks ago 72.7MB hms06/hello v1 d1165f221234 3 months ago 13.3kB hello-world latest d1165f221234 3 months ago 13.3kB centos latest 300e315adb2f 6 months ago 209MB vagrant@docker:~$ docker push hms06/hello:v1 The push refers to repository [docker.io/hms06/hello] f22b99068db9: Mounted from library/hello-world v1: digest: sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792 size: 525 vagrant@docker:~$ docker search naa02/hello:v1 NAME DESCRIPTION STARS OFFICIAL AUTOMATED vagrant@docker:~$ docker pull naa02/hello:v1 v1: Pulling from naa02/hello Digest: sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792 Status: Downloaded newer image for naa02/hello:v1 docker.io/naa02/hello:v1 vagrant@docker:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE wordpress 5.7.2 7e372e91d00b 33 hours ago 551MB wordpress latest 7e372e91d00b 33 hours ago 551MB haproxy 2.4.1 0d8843c089fb 6 days ago 95.4MB mysql 5.7 09361feeb475 8 days ago 447MB httpd latest 30287d899656 8 days ago 138MB debian latest 7a4951775d15 9 days ago 114MB ubuntu latest 9873176a8ff5 2 weeks ago 72.7MB hms06/hello v1 d1165f221234 3 months ago 13.3kB hello-world latest d1165f221234 3 months ago 13.3kB naa02/hello v1 d1165f221234 3 months ago 13.3kB centos latest 300e315adb2f 6 months ago 209MB vagrant@docker:~$ docker tag centos:latest centos:abc vagrant@docker:~$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE wordpress 5.7.2 7e372e91d00b 33 hours ago 551MB wordpress latest 7e372e91d00b 33 hours ago 551MB haproxy 2.4.1 0d8843c089fb 6 days ago 95.4MB mysql 5.7 09361feeb475 8 days ago 447MB httpd latest 30287d899656 8 days ago 138MB debian latest 7a4951775d15 9 days ago 114MB ubuntu latest 9873176a8ff5 2 weeks ago 72.7MB naa02/hello v1 d1165f221234 3 months ago 13.3kB hms06/hello v1 d1165f221234 3 months ago 13.3kB hello-world latest d1165f221234 3 months ago 13.3kB centos abc 300e315adb2f 6 months ago 209MB centos latest 300e315adb2f 6 months ago 209MB vagrant@docker:~$ docker logout

vagrant@docker:~$ docker run -it ubuntu bash
root@843caa65c0a9:/# apt install apache2
Please select the geographic area in which you live. Subsequent configuration questions will
narrow this down by presenting a list of cities, representing the time zones in which they are
located.
Progress: [ 67%] [##################################################..........................]
1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. SystemV 13. Etc
Progress: [ 67%] [###################################################..........................]
Progress: [ 67%] ####################################################..........................]
Geographic area: 6
Please select the city or region corresponding to your time zone.
Time zone: 69
root@843caa65c0a9:/# apachectl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
^C
#새로운 터미널로 확인
vagrant@docker:~$ curl 172.17.0.4 -I
HTTP/1.1 200 OK
Date: Fri, 02 Jul 2021 07:16:47 GMT
Server: Apache/2.4.48 (Unix)
Last-Modified: Fri, 02 Jul 2021 03:30:00 GMT
ETag: "5-5c61b920cc349"
Accept-Ranges: bytes
Content-Length: 5
Content-Type: text/html
root@843caa65c0a9:/# cd /var/www/html/
root@843caa65c0a9:/var/www/html# rm index.html
root@843caa65c0a9:/var/www/html# echo "hello world" > index.html
root@843caa65c0a9:/var/www/html# apachectl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
^C
#확인
vagrant@docker:~$ curl 172.17.0.3
hello world
root@843caa65c0a9:/var/www/html# apachectl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
^C
root@843caa65c0a9:/var/www/html# cd ..
root@843caa65c0a9:/var/www# cd ..
root@843caa65c0a9:/var# cd ..
root@843caa65c0a9:/# cd /etc/apache2
root@843caa65c0a9:/etc/apache2# sed -i -e 's/Listen 80/Listen 8080/g' ports.conf
-> listen 80을 8080으로 바꾸기. 하지만 실제파일 자체는 바뀌진 않음
root@843caa65c0a9:/etc/apache2# apachectl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
^C
#확인
vagrant@docker:~$ curl 172.17.0.3
curl: (7) Failed to connect to 172.17.0.3 port 80: Connection refused
vagrant@docker:~$ curl 172.17.0.3:8080
hello world
root@843caa65c0a9:/etc/apache2# cat ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 8080
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
root@843caa65c0a9:/etc/apache2# cd /tmp
root@843caa65c0a9:/tmp# echo "hello" > a
root@843caa65c0a9:/tmp# cat a
hello
root@843caa65c0a9:/tmp# cat <<EOF > b
> 1
> 2
> 3
> EOF
root@843caa65c0a9:/tmp# cat b
1
2
3
리눅스 sed 커맨드 꼭 공부하기
vagrant@docker:~$ docker commit 39 apache:v1 Error response from daemon: No such container: 39 vagrant@docker:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 843caa65c0a9 ubuntu "bash" 14 minutes ago Up 14 minutes eloquent_darwin e6fcad6e0fae haproxy:2.4.1 "docker-entrypoint.s…" 4 hours ago Up 4 hours 0.0.0.0:80->80/tcp, :::80->80/tcp lb a015f082d680 httpd "httpd-foreground" 4 hours ago Up 4 hours 80/tcp web2 e100481a8ecd httpd "httpd-foreground" 4 hours ago Up 4 hours 80/tcp web1 a7e00c249e65 wordpress:5.7.2 "docker-entrypoint.s…" 4 hours ago Exited (0) 4 hours ago wpweb 4ca78648829f mysql:5.7 "docker-entrypoint.s…" 4 hours ago Exited (0) 4 hours ago wpdb vagrant@docker:~$ docker commit 84 apache:v1 sha256:85889f828d193d6d083f3fd14b0a9bc72b785d6dcb4360f1d4a1a8e05880490c vagrant@docker:~$ docker run -d apache:v1 apachectl -D FOREGROUND 50af680afa75934faaee363d652bcab99191d8d035e1c750b39ce76f16414e7a vagrant@docker:~$ docker commit --change='CMD apachectl -D FOREGROUND' 84 apache:v2 sha256:b84540935d7fc1e3289ffed59b743b3ddee0651fe7a86fadb12f82d446cbb2a5 vagrant@docker:~$ docker run -d apache:v2 aefe2bfd483902910136e99bcbaa62cfbc1618b594c0ffd07f42b8be6a0c6249 vagrant@docker:~$ docker ps vagrant@docker:~$ docker image inspect ubuntu | tail vagrant@docker:~$ mkdir build vagrant@docker:~$ cd build/ vagrant@docker:~/build$ vi Dockerfile vagrant@docker:~/build$ cat Dockerfile FROM centos:7 COPY aaa /tmp/aaa vagrant@docker:~/build$ echo aaa > aaa vagrant@docker:~/build$ docker build -t myimage:v1 . vagrant@docker:~/build$ docker image inspect centos:7 | tail vagrant@docker:~/build$
Contents
소중한 공감 감사합니다