I followed this docker tutorial
https://docs.docker.com/compose/gettingstarted/
So i ended with a python app which is connects to Redis. When I go to http://localhost:5000/ I can see that every time I refresh the page, a counter adds up by 1. I also have a yml file, a requirements file and a dockerfile in my folder. In the end of the procedure I can run docker-compose up and see, as I said, the result of my work locally in my browser. So far so good.
Can i push all those in my docker hub, so as for others to pull them as an image and run them on their computer?
How do i push it in my hub?
What commands should others run to pull the image and run it in their computers?
2
Answers
You can only push single images to the hub. Not services nor whole compose files.
Before you push your image defined in
Dockerfile
, you must build it first withdocker build
. When you rundocker-compose up
, it performs the build for you.I would recommend you to go through a few guides around the basic docker commands like
docker build
,docker tag
anddocker run
. Manually doing the work docker-compose does for you helps to understand the container workflow.Docker Hub only allows you to upload images. As you’ve seen yourself, you can only publish the Python program. There are two ways you can allow consumers of your app to run both the services:
Dockerfile
. For example, keepubuntu
as the base image, useapt-get
to download Python, Redis, etc., andRUN
the required commands. This might seem easier, but it will prevent consumers from being able to spin up copies of services (e.g., they might want one Redis instance, but two Python instances).Note: Also look into Docker App.