How to push a Docker image?
-
After you create a docker image, you may want to store it on the docker hub.
-
Before you push it, you need to name your image with the right image name & tag name.
-
To check you docker image name & tag name, you may want:
BASHdocker image lsand you may see something like this:
BASHREPOSITORY TAG IMAGE ID CREATED SIZE<none> <none> a09c98bebda5 15 minutes ago 729MB -
Give your docker image a image name/tag:
BASHdocker image tag <image_id> <image_name>:<tag_name>For example:
BASHdocker image tag a09c98bebda5 j3ydocker/frontend:latest# to check it againdocker image lsREPOSITORY TAG IMAGE ID CREATED SIZEj3ydocker/frontend latest a09c98bebda5 39 minutes ago 729MB -
The
`<image_name>`
is also used to point to the correspond repository when you do the push. If your docker account is`j3ydocker`
you must name your image a name starting with`j3ydocker/.`
-
Now we can push it, just do:
BASHdocker image push j3ydocker/frontend