0

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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ian_Lane
  • 65
  • 1
  • 7
  • The documents on Docker regarding Push and Pull are pretty comprehensive. – dfundako Jun 15 '20 at 21:13
  • The documents on Docker regarding compose Push and Pull have in average 20% likes against 80% dislikes for a reason. Check for yourself. No, they are not pretty comprehensive. And please don't downvote my question. If you can help, if it is something easy, please help me. – Ian_Lane Jun 15 '20 at 21:26
  • "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?" Everything in your `compose.yml` will not be pushed to the docker hub. Only images are pushed there. – trallnag Jun 15 '20 at 21:28

2 Answers2

1

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.

Neel Kamath
  • 1,188
  • 16
  • 34
0

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.

trallnag
  • 2,041
  • 1
  • 17
  • 33
  • I know how to build, push, pull and run a simple application. Let me express my question in a more simplistic manner: I have an application like the one in the docker guide I posted in my original post. A python app that connects to Redis and it generates a result in ``localhost:5000`` . And I want someone else to be able to use what I have created. How do we get to this? I push just my Python app? What should the other person do to use my creation? Is he obliged to create a yml of his own? – Ian_Lane Jun 15 '20 at 21:48
  • 1
    Yes, the other person has to use the compose file as well. The only thing you can push is the app image itself – trallnag Jun 16 '20 at 07:21