Skip to content

How to create Docker Images for Docker Hub

Thuan Nguyen edited this page Jul 28, 2022 · 1 revision

Create a Docker Image

Using Dockerfile to Create an Image

  • Create Dockerfile
  • Build an image from Dockerfile
docker build -t android-lightweight .
  • Run a container based on the image
docker run -it --name android-lightweight-app android-lightweight

Create an image from a container

  • Pull a docker image
  • Create a container from it
  • Modify or make changes (e.g. install new app in that container)
  • Use docker commit command
docker commit android-lightweight-app android-lightweight:latest

Publish an image to Docker Hub

  • Sign up for Docker Hub
  • Create a repository on Docker Hub
  • Push image to Docker Hub
    • Log in: 1docker login1
    • Tag an image: 1docker tag android-lightweight:latest simplatex/android-lightweight:latest1
    • Publish the image: docker push simplatex/android-lightweight:latest
  • You can pull and test the image:
    • docker pull simplatex/android-lightweight:latest
    • docker run -it simplatex/android-lightweight:latest