I am running a docker image exactly as Centos / Docker Hub e.g.:
FROM centos:7 ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; VOLUME [ "/sys/fs/cgroup" ] CMD ["/usr/sbin/init"]
Then I simply install nginx just as in the documentation e.g.:
FROM local/c7-systemd RUN yum -y install nginx; yum clean all; systemctl enable nginx EXPOSE 80 CMD ["/usr/sbin/init"]
The container is build and it is running e.g.:
<CONTAINER ID> proxy-nginx:1.0.0 "/usr/sbin/init" 8 minutes ago Up 8 minutes 0.0.0.0:80->80/tcp
I ssh to the container to start the proxy but I am getting this error:
$ sudo docker exec -it <CONTAINER ID> /bin/bash [root@<CONTAINER ID> /]# systemctl start nginx Failed to get D-Bus connection: Operation not permitted
I even install nmap to scan the ports just as described here (5.8. Verifying Which Ports Are Listening).
But the response is that no ports are open:
# nmap -sT -O localhost Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-11 14:50 CEST Nmap scan report for localhost (127.0.0.1) Host is up (0.00020s latency). Other addresses for localhost (not scanned): 127.0.0.1 All 1000 scanned ports on localhost (127.0.0.1) are closed Too many fingerprints match this host to give specific OS details Network Distance: 0 hops OS detection performed. Please report any incorrect results at http://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 1.91 seconds
I then check the configurations (default) of the nginx and it looks okay:
# /usr/sbin/nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
The only way that I found on how to launch the proxy is to ssh to the container after and run:
How can I automate this process without the need to ssh to the container?
I tried to include:
But it is not working.
Has anyone found a solution?