Знакомство с Docker. Запускаем Apache в контейнере
How to manually build your own Apache HTTP server container on Docker
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 4a689991aa24 4 weeks ago 116MB
$ docker run -ti 4a689991aa24
root@1e0bbac5484b:/#
# apt update
# apt upgrade
# apt install mc nano
# apt-get install apache2 -y
# exit
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e0bbac5484b 4a689991aa24 "/bin/bash" 7 minutes ago Exited (0) 2 minutes ago hardcore_clarke
596a60786863 ubuntu:16.04 "/bin/bash" About an hour ago Exited (0) 42 minutes ago objective_volharduser@u1604:~$ docker commit 1e0bbac5484b
sha256:ecea558f5d2c8931cdf901abe19ad977e5703cb1481dfd3756e20827d1961cda
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> ecea558f5d2c 58 seconds ago 287MB
ubuntu 16.04 4a689991aa24 4 weeks ago 116MB
user@u1604:~$ docker tag ecea558f5d2c ubuntu-apache:v1
user@u1604:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-apache v1 ecea558f5d2c 2 minutes ago 287MB
ubuntu 16.04 4a689991aa24 4 weeks ago 116MB
$ docker run -p 8080:80 ubuntu-apache:v1 /usr/sbin/apache2ctl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Смотреть можно на host
http://<host ip>:8080/
Все работает!
How to mount a host directory in a Docker container
$ docker run -v /home/user/test:/test -p 8080:80 ubuntu-apache:v1 /usr/sbin/apache2ctl -D FOREGROUND
$ docker run -v /home/user/test:/test -it -p 8080:80 ubuntu-apache:v1
root@afc9b3f1e82f:/# /usr/sbin/apache2ctl -D FOREGROUND
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b90dfe76d156 ubuntu-apache:v1 "/usr/sbin/apache2..." 2 minutes ago Up 2 minutes 0.0.0.0:8080->80/tcp infallible_brattain
user@u1604:~$ docker exec -it b90dfe76d156 /bin/bash
root@b90dfe76d156:/#
Docker - a way to give access to a host USB or serial device?
Комментариев нет:
Отправить комментарий