let's assume you have already activated your certificate SSL so in other words, you have got the cert-chain.crt and the server.key or whatever name you've given to it, and let's assume you've got an nginx.conf file working already, let's create a folder in which you're going to create your Docker Image
and copy in there the next files:
cert-chain.crt
server.key
dist.zip
nginx.conf
this is the nginx.conf on centos
this is the nginx.conf on centos
let's create a file called Dockerfile, and inside of it let's paste
now let's create it with the command docker build -t nginx1 .
I gave it the name nginx1, give it the name as you want
now let's open the port 443 in the firewall with
firewall-cmd --zone="public" --add-port=443/tcp --permanent
to run it
docker run -p 443:443 --name nginxcontainer1 nginx1
Getting to the shell container:
If you need now to get to the shell, run this
docker exec -it --user root nginxcontainer1 bash
We have been able to deploy the Nginx app building the image and running it into a container,
now let's run it in the background or (Detached mode)
docker run -d --rm -p 443:443 --name nginxcontainer1 nginx1
-d = it means detached mode
-rm = it means if the container is running, it removes it before starting it again
-p = it is the port from the host forwarded to the container port
--name = it is the name of the container, in this case, nginxcontainer1
if you want to know if the container is running, just run docker container ps -a or docker container ls
Getting to the shell container:
If you need now to get to the shell, run this
docker exec -it --user root nginxcontainer1 bash
We have been able to deploy the Nginx app building the image and running it into a container,
now let's run it in the background or (Detached mode)
docker run -d --rm -p 443:443 --name nginxcontainer1 nginx1
-d = it means detached mode
-rm = it means if the container is running, it removes it before starting it again
-p = it is the port from the host forwarded to the container port
--name = it is the name of the container, in this case, nginxcontainer1
if you want to know if the container is running, just run docker container ps -a or docker container ls
Comments
Post a Comment