Search code examples
pythondockerredisdocker-composelinux-containers

Can I push a docker compose application for others to pull and run on their systems?


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?


Solution

  • 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:

    • In the documentation, such as on your Docker Hub repo's page, show what the Compose file should look like. Using this method, the consumer will have to write their own Compose file, but they'll copy-paste the other services exactly as you want them to. This is the recommended way, and is what other popular Docker Hub repos do.
    • You can create a monolithic Dockerfile. For example, keep ubuntu as the base image, use apt-get to download Python, Redis, etc., and RUN 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.