docker search nginx
docker pull nginx
docker run -d -ti nginx bash
- Get container name
docker ps -l
- Start some services in "background" docker.
- "admiring_dubinsky" is the name of container of my server, change it for yours.
docker exec -ti admiring_dubinsky bash -c "service nginx start"
- Get container IP:
docker inspect <containr-ID> | grep IP
- Is nginx running ?
curl <container-IP>
- Using iptables.
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp -d 0.0.0.0/32 --dport 80 -j DNAT --to-destination <container-ip>:80
iptables -t nat -A POSTROUTING -j MASQUERADE