Docker Hub
Last updated
Last updated
Sharing Docker images is made easy by Docker Hub. Anybody can create an account to Docker Hub to distribute images that can be deployed on other systems or by other users.
For this example, let us use an open source project from github. The TodoMVC using Nodejs, Vue, and Nuxt should be a great example. It is a demo application using JavaScript on the server and client.
Lets clone the project so that we have it on our computer. Cloning the git repository can be done with the following command:
This will download the project in a directory called todomvc
.
By default the project does not provide a Dockerfile. We will need to create one. An example could be:
This Dockerfile
will use a node image to provide the JavaScript runtime on the server. It will also install all dependencies using the npm package manager. Finally it will start the application using the npm start
command.
Lets build it using the command
You can test the container using the command
When everything works well, you could share the image using Docker Hub. You will need to create an account to be able to push (upload) an image and distribute it to other systems or developers.
When you have an account, you can log in to Docker Hub using the command
Before we can push the container we need to 'tag' it with a name. This can be done using the command
Now you are ready to push the image to Docker Hub using the command
The image is now available to anybody and a container be created from it and run using the command
You can now go to your Docker Hub and see your newly pushed image at
You should now be able to visit the webpage at