skip to Main Content

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


  1. 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?

    You can only push single images to the hub. Not services nor whole compose files.

    How do i push it in my hub?

    Before you push your image defined in Dockerfile, you must build it first with docker build. When you run docker-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 and docker run. Manually doing the work docker-compose does for you helps to understand the container workflow.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search