Skip to content

Upload Container to docker hub (part 2)

A quick note about how to upload a newly created container from docker hub by adding additional software before uploading it to docker hub. I am not as familiar with this favor of linux. Alpine is different from other linux and used a different package manager to install additional software. This distro we are using in our example is called Alpine linux. On Docker Hub, it is super light weight and came with a old Shell from unix. In this example, we will pull this docker image, add the BASH , commit it and package it then finally upload this new version to your Docker hub Free Account.

Pure example only for my personal recollection/ fullfillment.
flo@box: ~ $ docker pull alpine
# docker run -t -d --name {NameOfYourDockerInstance} alpine
flo@box: ~ $ docker run -t -d --name alpine_bash alpine
flo@box: ~ $ docker images
# docker exec -it {NameOfYourDockerInstance} sh
flo@box: ~ $ docker exec -it alpine_bash sh

Now, we are inside this instance of alpine as a virtualized container. We must now add additional software to this container before exiting it. Since our example is to install our favorite shell called bash. We will do so inside this container.

the prompt for alpine looked like this:
/ #
/ # apk update
/ # apk upgrade
/ # apk install bash
/ # exit

DONE with Alpine.

Now, you will have to log into your docker hub account and create a new public repo to hold this container from your local machine. Once done, the following instructions will apply to push this local instance to Docker hub.

Docker notation stated the following:
docker commit [options] [container ID] [repository:tag]

In my Docker hub container, i've named my local container as: alpine_bash.

flo@box : ~ $ docker container ps -a # will show the following
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
352b8a99458f alpine "/bin/sh" 8 seconds ago Up 7 seconds alpine_bash

We want to use the container ID as a parameter then the Dockerhub PUBLIC container you've created to hold this Docker Instance then some version reference which is shown after the colon.

flo@box: ~ $ docker commit 352b8a99458f freemanbach/nixcontainer:0.0.1

Before pushing your local docker instance to the cloud, you may want to consider using this command to authenticate with Docker Cloud service

flo@box: ~ $ docker login

flo@box: ~ $ docker push freemanbach/nixcontainer:0.0.1

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *