Register or Login to Your Account
How to create your image and push it to Docker hub?
I am taking here the example of creating an image based on latest Ubuntu image and push it to Docker hub. Below are the steps -
1. The first thing we must do is pull the latest Ubuntu image with the command:
docker pull ubuntu
The above command will pull down the latest Ubuntu image.
2. Now we're going to create a container such that we can work within our latest Ubuntu. To do this, issue the command:
docker run --name test-lamp-server -it ubuntu:latest bash
You can use any name you like in the above command. When the above command completes, you'll notice your terminal has changed to indicate you are now working within the container.
3. Once inside the container, the first thing you must do is update apt with the command:
If you do not issue the above command, you won't be able to install anything into the container.
4. Once the update completes, issue the command:
apt-get install lamp-server^
The above command will install everything you need for your lamp server.
5. When the installation is complete, you need to exit the container with the exit command. Issue the command docker ps -a and you should see the new container listed.
6. Now it's time we push our new container to Docker Hub. The first thing you must do is commit the change with the command:
docker commit -m "Added LAMP Server" -a "NAME" test-lamp-server USER/test-lamp-server:latest
Where NAME is your full name and USER is your Docker Hub user name.
7. Next we need to login to Docker Hub with the command:
You will be prompted for your Docker login credentials. Upon successful authentication, you will see Login Succeeded.
8. Finally, you can push your image to Docker Hub with the command:
docker push USER/test-lamp-server
Where USER is your Docker Hub user name.