2

docker-compose.yml

version: '2'
services:
  redis:
    image: redis
    ports:
      - "6379"
  myapp:
    build: ./myapp
    ports:
      - "80:80"
    links:
      - redis
    depends_on:
      - redis

Dockerfile of myapp

FROM <BASE_IMAGE>
EXPOSE 80
CMD ["curl", "http://redis"]

When I run docker-compose up -d --build and then docker run prefix_myapp_1, I'm getting the 'Host is not resolved' error after 4-5 seconds.

If I change the Dockerfile, say, as follows:

FROM <BASE_IMAGE>
EXPOSE 80
CMD sleep 1000000000

then do docker exec -it prefix_myapp_1 bash, and try running curl http://redis, the host is resolved successfully.

Where the problem lies?

Edward Ruchevits
  • 6,149
  • 12
  • 48
  • 84

0 Answers0