I have created a container with docker-compose in which there are two images with a Django application deployed (nginx to serve the static files and gunicorn as the web server). I want to share that container with people, but I don't know how to do it. I have read this question from another user and this one but I can't quite understand it ...
This is my container:
But when I run docker ps -a to see my containers, I don't get just one, I get 2 ...:
(venv) C:\Users\jmartinpe\Desktop\django_pegaso>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fea9f3f1f513 f455afd8b6b7 "/docker-entrypoint.…" 33 minutes ago Exited (0) 12 minutes ago django_pegaso_nginx_1
36e7a1c41d28 18df3392ccd3 "sh /entrypoint.sh" 33 minutes ago Exited (137) 12 minutes ago django_pegaso_django_gunicorn_1
And these are the two images that make up the container:
(venv) C:\Users\jmartinpe\Desktop\django_pegaso>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
django_pegaso_django_gunicorn latest 18df3392ccd3 33 minutes ago 459MB
django_pegaso_nginx latest f455afd8b6b7 2 hours ago 21.3MB
How could I export the container with the two images? With docker save Image> myImage.tar
it would only export an image, right?
This is my my docker-compose.yml:
version: '3.8'
services:
django_gunicorn:
volumes:
- static:/static
env_file:
- .env
build:
context: .
ports:
- "8000:8000"
nginx:
build: nginx
volumes:
- static:/static
ports:
- "8080:8080"
depends_on:
- django_gunicorn
volumes:
static:
UPDATE:
I have tried, as suggested in the comments, to save the images and move the two images together to the docker-compose.yml file to a directory, and run docker-compose up from that folder, but it gives me the error Error response from daemon: pull access denied for django_pegaso_nginx, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
.
(venv) C:\Users\jmartinpe\Desktop\django_pegaso>docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
django_pegaso_django_gunicorn latest 0265e0881fbe 2 minutes ago 459MB
django_pegaso_nginx latest f455afd8b6b7 19 hours ago 21.3MB
django_pegaso_debug latest c6b50343f25b 24 hours ago 750MB
(venv) C:\Users\jmartinpe\Desktop\django_pegaso>docker save 0265e0881fbe > django_pegaso_django_gunicorn.tar
(venv) C:\Users\jmartinpe\Desktop\django_pegaso>docker save f455afd8b6b7 > django_pegaso_nginx.tar
The steps I have followed have been:
- Save the images
- Move them to the same directory
- Create the docker-compose.yml in that directory
- Run docker-compose up
EDIT2:
I got it! Here is the guide that has helped me, in case it helps more people: https://eking-30347.medium.com/exporting-multiple-docker-images-alongside-docker-compose-f2db5d4a1632