How to run a Docker Compose image pulled from GitHub Packages
Asked Answered
A

1

7

I have pushed a Docker image on GitHub Packages and now I would like to pull it and use it. To run the image locally, I used to go to the related folder and run it with the command docker-compose up. However now, by pulling from GitHub Packages, I just get the Docker image without any folder and I don't know how I can run it.

By inspecting the image it has all the files related to the original folder but, when I try to run the docker-compose up ghcr.io/giuliomat/bdt-project command, I get an error saying that there is no docker-compose.yml in the directory. If I just use the command docker run ghcr.io/giuliomat/bdt-project it runs one of the two services specified in the docker-compose.yml file. How can I run the Docker Compose image correctly? Thanks in advance!

Update: I try to explain myself better. In the image there is a Dockerfile (that now I've uploaded in the question) which is used to build the web service. I developed the image locally and I have no problem running it with docker-compose up, but now I wanted to see what it has to be done in order to run it when a user pulls it from my GitHub Packages, and this is my problem. The pulled image should have all the elements needed to run but I don't know what command to use in order to tell Docker to run both services specified in the docker-compose.yml file, since when a user pulls from GitHub Packages it only gets the image and no folder where run docker-compose up.

Dockerfile:

enter image description here

docker-compose.yml:

enter image description here

content of the pulled docker image:

enter image description here

Abscission answered 13/7, 2021 at 17:35 Comment(0)
M
6

Update:

Docker image repository does not store yml files, therefore either you provide a README.md for the user in the image registry (with yml verbosely copy-pasted there) and/or you provide also the link to the version control repository where the rest of the files reside, so the user can clone and use docker-compose up.


docker-compose up [options] [--scale SERVICE=NUM...] [SERVICE...] means "find [service...](if specified, otherwise run all) indocker-compose.yml` in the current working directory and run it.

So if you move out of the folder with docker-compose.yml it won't pick the compose file and therefore won't work.

Also for the image using you need to specify image property of a service instead of build because build works with the Dockerfile locally and attempts to build an image instead of pulling it from GitHub Docker image registry:

web:
  image: "ghcr.io/giuliomat/bdt-project:latest"

It'd be the same way you have it for redis service.

Also make sure you can pull the image locally first (otherwise docker login would be necessary prior to compose commands) by:

docker pull ghcr.io/giuliomat/bdt-project
Mccleary answered 14/7, 2021 at 6:26 Comment(2)
Thank you for your answer. However, maybe because I didn't explain myself well, it does not solve my problem. I've updated the question so I think now it's more clear, my problem is not in the pulling process but in running the image, telling Docker to run both services specified in the docker-compose.yml file contained in the image.Abscission
That's unfortunate. I will do as you suggested and push on GitHub just the web service and add the docker-compose.yml on the repository with the instructions. Thanks a lot for time and help. I appreciate itAbscission

© 2022 - 2024 — McMap. All rights reserved.