본문 바로가기
Container

Docker httpd image 생성 절차

by Royal! 2023. 5. 16.
728x90
반응형

1. httpd image를 이용해서 h1이름의 Container 생성

1.1 컨테이너의 80port를 host의 65080 포트 포워딩

1.2 시작 페이지를 Docker WEB SERVER로 출력

 

2. 위의 과정을 Container Life Cycle형태로 제작

2.1 docker create

2.2 docker start

2.3 docker pause 수행 후 웹페이지 접근 여부

2.4 docker unpause 수행 후 웹페이지 접근여부


[root@localhost ~]# docker create -p 65080:80 --name h1 httpd
d31c2677ae278eb6e283097a83b128525df9ea75bd33d5f92d567de4f60382b4
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker start h1
h1
[root@localhost ~]# docker pause h1
h1
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND              CREATED          STATUS                      PORTS                                     NAMES
d31c2677ae27   httpd     "httpd-foreground"   39 seconds ago   Up 30 seconds (Paused)      0.0.0.0:65080->80/tcp, :::65080->80/tcp   h1
0dc6a31fff36   httpd     "httpd-foreground"   22 minutes ago   Exited (0) 16 minutes ago                                             h2
dcb2ae75c94a   alpine    "/bin/sh"            2 hours ago      Up 2 hours                                                            a2
f4a597559878   alpine    "/bin/sh"            2 hours ago      Up 2 hours                                                            suspicious_tesla
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND              CREATED          STATUS                      PORTS                                     NAMES
d31c2677ae27   httpd     "httpd-foreground"   43 seconds ago   Up 33 seconds (Paused)      0.0.0.0:65080->80/tcp, :::65080->80/tcp   h1
0dc6a31fff36   httpd     "httpd-foreground"   22 minutes ago   Exited (0) 16 minutes ago                                             h2
dcb2ae75c94a   alpine    "/bin/sh"            2 hours ago      Up 2 hours                                                            a2
f4a597559878   alpine    "/bin/sh"            2 hours ago      Up 2 hours                                                            suspicious_tesla
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker exec -it h1 /bin/bash
Error response from daemon: Container h1 is paused, unpause the container before exec
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker unpause h1
h1
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker exec -it h1 /bin/bash
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# echo "Docker WEB SERVER" > htdocs/index.html
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# 
root@d31c2677ae27:/usr/local/apache2# exit
exit
[root@localhost ~]# docker pause h1
h1
[root@localhost ~]# docker unpause h1
h1


결과

728x90
반응형

'Container' 카테고리의 다른 글

Docker save, load, tar, scp 명령어 실습  (0) 2023.05.17
Docker 복사(CP) 실습 예제  (0) 2023.05.17
Docker에서 HaProxy 활용하여 Load Balance  (0) 2023.05.16
Container LifeCycle  (0) 2023.05.16
Docker 이미지 및 명령어 모음  (0) 2023.05.16

최근댓글

최근글

Royal! © 2024