I wrote a docker-compose.yml
file referencing this tutorial: Running PostGraphile in Docker, but when I run this command docker-compose pull && docker-compose up -d
to update an image an error occurred:
WARNING: Some service image(s) must be built from source by running:
docker compose build graphql
Error response from daemon: pull access denied for forum-example-graphql, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
But if I run docker-compose up -d
, everything is OK.
I wonder how the forum-example-graphql
image in the following snippet can be found(from docker hub?)?
graphql:
container_name: forum-example-graphql
restart: always
image: forum-example-graphql
build:
context: ./graphql
env_file:
- ./.env
depends_on:
- db
networks:
- network
ports:
- 5433:5433
command: ["--connection", "${DATABASE_URL}", "--port", "5433", "--schema", "public", "--append-plugins", "postgraphile-plugin-connection-filter"]
I learned from here that the image name in the compose file is based on the created image name, but I did not name the local image as forum-example-graphql
.
In another service the configuration is as follows:
postgres:
container_name: postgres
image: postgres:latest
restart: always
volumes:
- "./postgres-data:/var/lib/postgresql/data"
networks:
- network
ports:
- "5432:5432"
The image value is set as postgres:latest
and the image is pulled directly from docker hub using this config, given no context and Dockerfile.
Then I wonder how the local image is named and how does it relate to the service image value.
2
Answers
docker-compose pull, pulls the image
forum-example-graphql
from the image registry, default (docker hub).but since it is specified to be built from the directory
Hence, that image need not be pulled, you can use this option
--ignore-buildable
withdocker-compose pull
to skip images with local build context.Also
docker-compose up -d
by default pulls image if not available and smartly ignores local contexts and pulls images which are to be pulled.It is not possible to do a
docker-compose pull
command on theforum-example-graphql
-docker, because it does not exist in the publically accessible Docker Hub repository. Part of the tutorial is that you create that image yourself by usingdocker-compose build
(see here).After performing the
build
command, you can use theup -d
to start the image that you build (namedforum-example-graphql
).