How to create and upload a Docker Image from a Dockerfile
-
If you are wanting to upload your image to Docker, then you will need to make sure that you are logged in with the terminal. To do that you can follow this link and it will explain how to do that. Click Here
In the folder that your
Dockerfileis in, run this command:sudo docker build -t image_name .Replace
image_namewith the name that you want to use for your Docker Image.
Next we need to set the version of your image. To do that use this command:
sudo docker tag image_name:latest docker_username/image_name:tagReplace
image_namein both areas of the command with the same name that you used in the first step. Then replacedocker_usernamewith your DockerHub username. You will also need to specify atagfor your Docker Image. By default it will belatest, but if you have a specific version of your image you are building, you would put it here.
The last step is pushing our file to DockerHub. To do that we need to run this command:
sudo docker push docker_username/image_name:tagYou’ll need to update
docker_username,image_nameandtagto whatever you put in the last command.