搬运工-compose.yml
version: '2'
services:
redis:
image: redis
ports:
- "6379"
myapp:
build: ./myapp
ports:
- "80:80"
links:
- redis
depends_on:
- redis
myapp
FROM <BASE_IMAGE>
EXPOSE 80
CMD ["curl", "http://redis"]
当我运行docker-compose up -d --build
然后docker run prefix_myapp_1
时,我在4-5秒后收到'主机未解决'错误。
如果我更改Dockerfile,请按如下方式更改:
FROM <BASE_IMAGE>
EXPOSE 80
CMD sleep 1000000000
然后执行docker exec -it prefix_myapp_1 bash
,并尝试运行curl http://redis
,主机已成功解析。
问题出在哪里?