How to publish images to Docker Hub
                PUBLISHED
                13 JANUARY 2022
            
Create a file named Dockerfile and write the contents below
1
2
3
FROM jekyll/builder:3.8
RUN apk add --update --no-cache nodejs npm
RUN gem install kramdown-math-katex bundler
 
Then build the docker image from Dockerfile using docker build . -t image_name:tag_name, where the tag is optional
1
2
# format: docker pull image_name:tag_name
docker pull jekyll/builder:3.8
 
1
2
3
docker run --rm -it jekyll/builder:3.8 bash
mkdir test-directory/
exit
 
NOTE:
docker run ... -i image_name:tag_name bash -c "command_name" to execute commands through the container--rm for automatic clean up of containers upon exiting the container
1
2
3
4
5
6
docker ps -a
# example output
CONTAINER ID   IMAGE            COMMAND                  CREATED        ...
d96a67fbc97f   jekyll-builder   "/usr/jekyll/bin/ent…"   21 hours ago   ...
ba05b0a4b940   b5dd64e479c8     "/usr/jekyll/bin/ent…"   22 hours ago   ...
 
where you will see a 12 character string under CONTAINER ID
Before proceeding, ensure that you are logged into docker hub by running docker login
1
2
3
docker commit container_id dockerhub_username/repository:tag_name
# for example
docker commit d96a67fbc97f evantancy/test-repo:latest
 
1
docker push evantancy/test-repo:latest
 
Now head on over to Docker Hub and your custom image is there! I’ve managed to find a great video on this here.