DEV Community

GaMa
GaMa

Posted on • Edited on

6 1

Creating a Docker image and upload it to Docker Hub

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
Enter fullscreen mode Exit fullscreen mode

Then, to build the docker image run:

docker build -t username/imagename:latest .
Enter fullscreen mode Exit fullscreen mode

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 .
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Finally we can push the Docker image to the Hub:

docker push ech0server/multigitaccount:latest
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay