Step 1

Go to https://hub.docker.com and create an account, if you haven’t yet

Step 2

Prepare Dockerfile that will be source of your Docker image. Here is a simple one:

Step 3

Run terminal and go to directory where Dockerfile is located (prepared in previous step)

Step 4

Build image using docker build command and Dockerfile prepared in 2nd step:

Step 5

Use the docker login command to login to your account created in 1st step:

Step 6

Upload created image to Docker Hub using docker push command

Step 7

If you open your Docker’s profile, you will see your new image. Image used as an example: https://hub.docker.com/r/kniziol/php.

Step 8

Finally, use created and pushed image to create container and service: