Reputation: 650
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:
docker-compose.yml:
content of the pulled docker image:
Upvotes: 8
Views: 13143
Reputation: 12199
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) in
docker-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
Upvotes: 7