Fedora 24
Sponsored Link

Docker : Access to Container Environment
2016/06/30
 
If you'd like to access to services like HTTP or SSH which is running in Containers as a daemon, set like follows.
[1] For exmaple, use a Container which has httpd.
# start the Container and connect to the shell session

# map the port of Host and the port of Container with "-p xxx:xxx"

[root@dlp ~]#
docker run -it -p 8081:80 images/fedora_httpd /bin/bash
# start httpd and exit the Container

[root@8ed85454810b /]#
/usr/sbin/httpd &

[root@8ed85454810b /]#
echo "httpd on Docker Container" > /var/www/html/index.html

[root@8ed85454810b /]#    
# Ctrl+p, Ctrl+q key
[root@dlp ~]#
docker ps

CONTAINER ID    IMAGE                 COMMAND      CREATED         STATUS         PORTS                  NAMES
8ed85454810b    images/fedora_httpd   "/bin/bash"  59 seconds ago  Up 56 seconds  0.0.0.0:8081->80/tcp   fervent_franklin

# verify possible to access or not

[root@dlp ~]#
curl http://localhost:8081

httpd on Docker Container
Matched Content
 
Tweet