Docker Community Forums

Share and learn in the Docker community.

Docker container on server using systemctl and nginx

I am quite new to docker and am in the process of deploying a python flask application using docker on a redhat virtual box.

So far I have followed a few basic tutorials to build a docker file to establish an image to use, commands to run, ports to expose etc. All of that makes sense to me.

However also on this virtual box, are quite a few different web services deployed using nginx and systemctl.

The instructions I previously followed are roughly (using nginx, gunicorn, systemctl):

#
# reverse proxy, map URL to localhost port
/etc/nginx/nginx.conf
# make service unit file
# example <service>.service with basic ExecStart cmd, Restart etc.
# systemctl stuff
Systemctl daemon-reload / systemctl enable [service] / systemctl start [service]
Gunicorn is importing a method from a Python module
systemctl reload nginx
####

At this point I am quite confused on how to run a docker container using nginx - or really where the scope of the docker container stops and the systemwide environment begins i.e. Is it necessary to do reverse proxy’ing on the system wide nginx.conf or would I have a separate nginx on the docker container? Do I need to run systemctl?

I am not necessarily trying to exactly follow the above directions, just trying to mimic the general behavior - reverse proxy, automatic restarts, etc. .

Sorry these may be silly questions, I do not understand docker well enough to generalize and ask intelligent questions quite yet. If anyone could even help re-interpret my question would be greatly appreciated.

The docker exec command runs a specified command within an already running container. You can use it to SSH into a Docker container by creating a bash shell (a shell where you can type commands).

Start by pulling a Docker image if you haven’t already. For example, you can load Nginx:

sudo docker pull nginx
docker pull image in command line
Then, run the image:

sudo docker run ––name nginx–test –d nginx
docker run image command in the linux terminal
List all running containers to verify:

sudo docker ps
You should now see your nginx-test image loaded.

docker ps command to list all running docker containers
To get access and run commands in that Docker container, type the following:

sudo docker exec –it nginx-test /bin/bash
Now, you are logged in to the nginx-test container. Therefore, any commands you enter will perform in that container. The –i option specifies interactive, and the –t enables a terminal typing interface.