Running the containers
In the previous chapter, we used PM2 to manage the lifecycle of our application. This time, we will do it differently: we will use Docker directly.
Our first step will be to install Docker on our target machine using SSH. Follow the installation guide (https://docs.docker.com/engine/install/ubuntu/) and then run docker run hello-world
. The command will run without generating any error, this was a simple test to check whether the Docker engine was properly set up and running.
Please check that you stopped the PM2 application before we move to the next step as only one service can control port 3000
. Then, our last step will be to run the container but, this time, we won’t need to build the container as we are pulling directly the image from Docker Hub:
docker run \ -e MONGODB_URI='mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority' \ -e PORT='3000' \ -e SALT_ROUNDS='10...