Docker Community Forums

Share and learn in the Docker community.

Docker ubuntu, then nginx and php, cannot start web server

docker pull ubuntu
then run as daemon docker run -i -d -t php /bin/bash
access image
docker exec -it 95a8b7426b2d /bin/bash

install manually nginx from ubuntu repo
apt-get install nginx 1.10
then php-fpm

then commit as php image to save work, otherwise all work lost

nect: permission denied
gin@ubuntu:~$ sudo -i
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 16 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 17 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~#

run nginx as server
docker run -p 8080:80 -d --name webserver2 php

cannot access docker webserver
docker sits in vmware ubuntu

please help

Why do I have to docker pull nginx in order to start nginx server?
I do not want debian, I need ubuntu

gin@ubuntu:~$ sudo -i
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 16 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 17 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker run -p 8080:80 -d --name webserver2 php
4cad67eb1dcc4c0247158cacf1d84847d252a4798f02671f7701042351cd2232
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 17 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cad67eb1dcc php “/bin/bash” 7 seconds ago Exited (0) 7 seconds ago webserver2
root@ubuntu:~#

nginx is running ok
nginx latest 4e5e9d21972f 17 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cad67eb1dcc php “/bin/bash” 7 seconds ago Exited (0) 7 seconds ago webserver2
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cad67eb1dcc php “/bin/bash” 2 minutes ago Exited (0) 2 minutes ago webserver2
root@ubuntu:~# docker run -i -d -t php /bin/bash
f0f12da87a66d732bba83fb0065de84ff15d033972857c51b1d626db26d0d025
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0f12da87a66 php “/bin/bash” 4 seconds ago Up 3 seconds modest_poitras
4cad67eb1dcc php “/bin/bash” 3 minutes ago Exited (0) 3 minutes ago webserver2
root@ubuntu:~# docker exec -it 95a8b7426b2d /bin/bash
Error response from daemon: No such container: 95a8b7426b2d
root@ubuntu:~# ^C
root@ubuntu:~# docker exec -it modest_poitras /bin/bash
root@f0f12da87a66:/# top

  • 18:14:04 up 1 day, 16:10, 0 users, load average: 0.00, 0.00, 0.00
    Tasks: 3 total, 1 running, 2 sleeping, 0 stopped, 0 zombie
    %Cpu(s): 0.6 us, 1.0 sy, 0.0 ni, 98.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
    KiB Mem : 4026832 total, 371340 free, 1906760 used, 1748732 buff/cache
    KiB Swap: 4192252 total, 4110332 free, 81920 used. 1644384 avail Mem

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    1 root 20 0 18240 3248 2792 S 0.0 0.1 0:00.02 bash
    11 root 20 0 18248 3252 2776 S 0.0 0.1 0:00.01 bash
    21 root 20 0 36668 3012 2524 R 0.0 0.1 0:00.00 top

root@f0f12da87a66:/# nginx -v
nginx version: nginx/1.10.0 (Ubuntu)
root@f0f12da87a66:/# nginx -V
nginx version: nginx/1.10.0 (Ubuntu)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt=’-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2’ --with-ld-opt=’-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now’ --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
root@f0f12da87a66:/#

–with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
root@f0f12da87a66:/# nginx
root@f0f12da87a66:/# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
root@f0f12da87a66:/#

p - 18:14:50 up 1 day, 16:11, 0 users, load average: 0.04, 0.01, 0.00
Tasks: 8 total, 1 running, 7 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.6 us, 1.0 sy, 0.0 ni, 98.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 4026832 total, 365432 free, 1909552 used, 1751848 buff/cache
KiB Swap: 4192252 total, 4110332 free, 81920 used. 1641428 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 18240 3248 2792 S 0.0 0.1 0:00.02 bash
11 root 20 0 18248 3268 2776 S 0.0 0.1 0:00.02 bash
25 root 20 0 124972 1436 80 S 0.0 0.0 0:00.00 nginx
26 www-data 20 0 125332 3024 1440 S 0.0 0.1 0:00.00 nginx
27 www-data 20 0 125332 3024 1440 S 0.0 0.1 0:00.00 nginx
28 www-data 20 0 125332 3024 1440 S 0.0 0.1 0:00.00 nginx
29 www-data 20 0 125332 3024 1440 S 0.0 0.1 0:00.00 nginx
31 root 20 0 36668 3168 2672 R 0.0 0.1 0:00.00 top

root@f0f12da87a66:/# exit
exit
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0f12da87a66 php “/bin/bash” 2 minutes ago Up 2 minutes modest_poitras
4cad67eb1dcc php “/bin/bash” 6 minutes ago Exited (0) 6 minutes ago webserver2
root@ubuntu:~#

exit
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0f12da87a66 php “/bin/bash” 2 minutes ago Up 2 minutes modest_poitras
4cad67eb1dcc php “/bin/bash” 6 minutes ago Exited (0) 6 minutes ago webserver2
root@ubuntu:~# docker exec -it modest_poitras nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
root@ubuntu:~#

If I try to use port mapping it nginx just exits

root@ubuntu:~# docker run -p 8080:80 -d modest_poitras nginx
Unable to find image ‘modest_poitras:latest’ locally
docker: Error response from daemon: repository modest_poitras not found: does not exist or no pull access.
See ‘docker run --help’.
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php latest 2a94341ed061 16 hours ago 234MB
nginx latest 4e5e9d21972f 17 hours ago 213MB
ubuntu latest ebcd9d4fca80 2 weeks ago 118MB
root@ubuntu:~# docker run -p 8080:80 -d php nginx
2ed2e65505d6441f87b92bc94f2310188efaa96b58b18f7d6dfe056b57ce685a
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0f12da87a66 php “/bin/bash” 4 minutes ago Up 4 minutes modest_poitras
root@ubuntu:~# dock ps -a
No command ‘dock’ found, did you mean:
Command ‘mock’ from package ‘mock’ (universe)
Command ‘docky’ from package ‘docky’ (universe)
Command ‘dbck’ from package ‘lyskom-server’ (universe)
Command ‘doc8’ from package ‘python3-doc8’ (universe)
Command ‘doc8’ from package ‘python-doc8’ (universe)
Command ‘dtck’ from package ‘dnssec-tools’ (universe)
Command ‘duck’ from package ‘duck’ (universe)
dock: command not found
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ed2e65505d6 php “nginx” 14 seconds ago Exited (0) 13 seconds ago wonderful_newton
f0f12da87a66 php “/bin/bash” 5 minutes ago Up 4 minutes modest_poitras
4cad67eb1dcc php “/bin/bash” 8 minutes ago Exited (0) 8 minutes ago webserver2
root@ubuntu:~#