Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Compose does not allow to use local images

The following command fails, trying to pull image from the Docker Hub:

$ docker-compose up -d Pulling web-server (web-server:staging)... ERROR: repository web-server not found: does not exist or no pull access 

But I just want to use a local version of the image, which exists:

$ docker images REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE web-server           staging             b94573990687        7 hours ago         365MB 

Why Docker doesn't search among locally stored images?


This is my Docker Compose file:

version: '3' services:   chat-server:     image: chat-server:staging     ports:       - "8110:8110"   web-server:     image: web-server:staging     ports:       - "80:80"       - "443:443"       - "8009:8009"       - "8443:8443" 

and my .env file:

DOCKER_HOST=tcp://***.***.**.**:2376 DOCKER_TLS_VERIFY=true  DOCKER_CERT_PATH=/Users/Victor/Documents/Development/projects/.../target/docker 
like image 662
Victor Dombrovsky Avatar asked Sep 04 '17 07:09

Victor Dombrovsky


People also ask

Can I use local image in Docker compose?

Docker Compose does not allow to use local images.

Is Docker compose local?

You can use Docker Compose to define your local development environment, including environment variables, ports you need accessible, and volumes to mount. Everything is defined in docker-compose. yml , which is used by the docker-compose CLI. The first section defines the web service.


1 Answers

In general, this should work as you describe it. Tried to reproduce it, but it simply worked...

Folder structure:

. ├── docker-compose.yml └── Dockerfile 

Content of Dockerfile:

FROM alpine CMD ["echo", "i am groot"] 

Build and tag image:

docker build -t groot . docker tag groot:latest groot:staging 

with docker-compose.yml:

version: '3.1' services:   groot:     image: groot:staging 

and start docker-compose:

$ docker-compose up Creating groot_groot ...  Creating groot_groot_1 ... done Attaching to groot_groot_1 groot_1  | i am groot groot_groot_1 exited with code 0 
like image 66
n2o Avatar answered Sep 21 '22 23:09

n2o