View on GitHub


Jupiter System - Collaborative Editing - Applied to Sticky Notes

Download this project as a .zip file Download this project as a tar.gz file

This article deals with how to use Docker to easily deploy our nodeJS application on another machine.

Creating an image

Once you are done coding, go to the root of your folder. It should contain a Dockerfile. Don't forget to add what is necessary if you have modified the contents (by using additional modules for example).

Open a terminal where the Dockerfile is located then type : $ sudo docker build -t [username]/docpal .

Once the operations are completed, check if this newly created image is present in your image list : $ sudo docker images

docker images

Uploading the image

First,you need to create an account on here. Now, login : $ sudo docker login

Once you are authenticated, if you want to transfer the state of a running container to your image, you need to commit a container to an image : $ sudo docker commit [containerID] [username]/docpal Otherwise, you can skip this step. Be careful : if your container has already started the server and if you commit this state to an image, it will be useless as when running a container from this commited image, the server is supposed to have been started, which isn't necessarily the case.

Then push the image to its repository : $ sudo docker push [username]/docpal

Make sure that your image has been uploaded. If you type : $ sudo docker search [username]/docpal, you should be able to see it. Otherwise, do the provious steps again.

Deploying a container

Once you are connected via SSH to your remote virtual machine (see here ), type : $ sudo docker pull polo417/docpal

Then make sure the image is present in your image list : $ sudo docker images

If so, just run it : $ sudo docker run [username]/docpal

Check if your container is running and remember its ID: $ sudo docker ps And have a look at the field "Ports". "Port2"->"Port1" means that the original port "Port1" was mapped to "Port2" in the container.

docker ps

To see the output of the application and see if no error occurred : $ sudo docker logs [containerID]

Now call your application using curl (type $ yum install curl if necessary) : $ curl -i localhost:[Port2]

Congratulations ! Your application should be running and you should be able to access it via a web browser by typting : [Floating IP address]:[Port2].

NB : don't forget to allow Port2 on Openstack !