I ve created my own docker file ( that runs a shell script which prints "helloworld"). The image is "hellodocker" and the tag is "mytag" I now have:
bash-3.2$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
hellodocker mytag 3514c8dc11a8 39 minutes ago 2.433 MB
busybox buildroot-2013.08.1 d200959a3e91 10 weeks ago 2.489 MB
busybox ubuntu-14.04 37fca75d01ff 10 weeks ago 5.609 MB
busybox ubuntu-12.04 fd5373b3d938 10 weeks ago 5.455 MB
busybox buildroot-2014.02 a9eb17255234 10 weeks ago 2.433 MB
busybox latest a9eb17255234 10 weeks ago 2.433 MB
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97c29510069e hellodocker:mytag /bin/sh -c /Users/in 33 minutes ago Exited (127) 26 minutes ago happy_pasteur
8d04a1385c24 hellodocker:mytag /bin/sh -c /Users/in 37 minutes ago Exited (127) 30 minutes ago mad_bell
8998d61c0513 hellodocker:mytag /bin/sh -c /Users/in 37 minutes ago Exited (127) 30 minutes ago boring_thompson
64314c304a29 hellodocker:mytag /bin/sh -c /Users/in 37 minutes ago Exited (127) 31 minutes ago sad_wilson
8bc20e0555b8 hellodocker:mytag /bin/sh -c /Users/in 38 minutes ago Exited (127) 31 minutes ago sleepy_mayer
97664a4ba870 hellodocker:mytag . 38 minutes ago kickass_poincare
8bb752631cb6 busybox:buildroot-2014.02 /bin/echo Hello Doct 18 hours ago Exited (0) 18 hours ago dreamy_kowalevski
6aa66b55ca94 busybox:buildroot-2014.02 bash-3.2$ sudo docke 18 hours ago ecstatic_lovelace
2cc657f65342 busybox:buildroot-2014.02 /bin/echo Hello Dock 18 hours ago Exited (0) 18 hours ago dreamy_poincare
How do I push the docker image to dockerhub? I use docker push <myuserid>/hellodocker
. This gives a 'no such id` error. What am I missing? Thanks in advance.
First go to your Docker Hub account and make the repo. Here is a screenshot of my Docker Hub account:
From the pic, you can see my repo is “chuangg”
HOW TO UPLOAD YOUR DOCKER IMAGE ONTO DOCKER HUB
Method #1= Pushing your image through the command line (cli)
1)
docker commit <container ID> <repo name>/<Name you want to give the image>
Yes, I think it has to be the container ID. It probably cannot be the image ID.
For example=
docker commit 99e078826312 chuangg/gene_commited_image
2)
docker run -it chaung/gene_commited_image
3)
docker login --username=<user username> --email=<user email address>
For example=
docker login --username=chuangg --email=gc.genechaung@gmail.com
Yes, you have to login first. Logout using “docker logout”
4)
docker push chuangg/gene_commited_image
Method #2= Pushing your image using pom.xml and command line.
Note, I used a Maven Profile called “build-docker”. If you don’t want to use a profile, just remove the
<profiles>, <profile>, and <id>build-docker</id>
elements.Inside the parent pom.xml:
Docker Terminal Command to deploy the Docker Image (from the directory where your pom.xml is located)=
mvn clean deploy -Pbuild-docker docker:push
For those of you not using a Maven Profile, the command would simply be
mvn clean deploy docker:push
Note, the difference between Method #2 and #3 is that Method #3 has an extra
<execution>
for the deployment.Method #3= Using Maven to automatically deploy to Docker Hub
Add this stuff to your parent pom.xml:
Go to C:\Users\Gene.docker\ directory and add this to your config.json file:
Now in your Docker Quickstart Terminal type=
mvn clean install -Pbuild-docker
For those of you not using a Profile, just type
mvn clean install
Here is a screenshot of what it will look like if it works:
Here is my full pom.xml and a screenshot of my directory structure:
Here is my Eclipse Directory:
Here is my Dockerfile:
Common Error #1:
Solution for Error #1= Do not sync the
<execution>
with maven deploy phase because then maven tries to deploy the image 2x and puts a timestamp on the jar. That’s why I used<phase>install</phase>
.If you want
hellodocker
repository undermyuserid
namespace, you have to first tag your localhellodocker
tomyuserid
like:And then push this
myuserid/hellodocker
repository to hub like:You either need to tag it as
<myuser>/hellodocker
when you build it, e gor create a new tag tied to the same image, i e