I have a docker-compose file:
version: '3.4'
services:
nginx:
container_name: some-nginx
image: nginx:latest
restart: always
ports:
- 80:80
- 443:443
mongodb:
container_name: some-mongo
image: mongo:latest
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
ports:
- 27017:27017
command: mongod --smallfiles --logpath=/dev/null # --quiet
I want to push to Amazon Elastic Container Registry (ECR), using the commands:
docker tag testapper:latest 619625705037.dkr.ecr.us-east-2.amazonaws.com/testapper:latest
But I got an message:
Error response from daemon: No such image: testapper:latest
When I run docker-compose build
I got this message:
nginx uses an image, skipping
mongodb uses an image, skipping
What does this mean? How do push my images to ECR?
Your docker containers are all using existing images (image
keyword)
services:
nginx:
image: nginx:latest
mongodb:
image: mongo:latest
therefore you do not need to build them.
I believe ECS will find these official images by itself, so you do not need to push them to your private repo (ECR). (not 100% sure)
In case you do want to push a custom built image, the general flow is
docker build -t your_image_name:tag path
docker tag your_image_name:tag 619625705037.dkr.ecr.us-east-2.amazonaws.com/your_image_name:tag
# or
docker build -t 619625705037.dkr.ecr.us-east-2.amazonaws.com/your_image_name:tag path
docker push 619625705037.dkr.ecr.us-east-2.amazonaws.com/your_image_name:tag
You can use docker-compose build
to build and tag at the same time if your compose file is like
services:
nginx:
image: 619625705037.dkr.ecr.us-east-2.amazonaws.com/your_image_name:tag
build: ./my-nginx-path