loading...

Creating a Docker image and upload it to Docker Hub

ech0server profile image GaMa Updated on ・1 min read

Creating the Docker image

I'm going to use a Docker image to be able to use multiple github accounts from the same machine without so much trouble. To keep the image small I will use Alpine as a base image and only install the basics: git, vim, openssh-client.

In order to build the image we need to create a new file called Dockerfile and write the following:

FROM alpine:latest

LABEL maintainer="@ech0Server"

RUN apk update
RUN apk add git vim openssh-client

Then, to build the docker image run:

docker build -t username/imagename:latest .

This command not only will build the image but it will tag it with the -t option, for my case I did:

docker build -t ech0server/multigitaccount:latest .

I will assume that you already have a Docker Hub account or create a docker hub account, then:

$ export DOCKER_ID_USER="username"
$ docker login #it will prompt you for your username and password

If you followed the previous instructions your image should be already tagged, if not then you can tag your image by:

docker tag my_image $DOCKER_ID_USER/my_image

Finally we can push the Docker image to the Hub:

docker push ech0server/multigitaccount:latest

After that is completed you can go to: https://hub.docker.com/u/username and see that the image was successfully uploaded.

My image can be found here: https://hub.docker.com/r/ech0server/multigitaccount/

And you can pull it by doing:

docker pull ech0server/multigitaccount

Posted on Sep 12 '17 by:

Discussion

markdown guide