I'm using the following version of Docker
$ docker -v
Docker version 20.10.7, build f0df350
When I start my containers using "docker-compose up", I can see them all come up with
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29e94e032fbb maps_apache "httpd-foreground" 2 minutes ago Up 2 minutes 0.0.0.0:9090->80/tcp, :::9090->80/tcp maps_apache_1
13a8f2f037e4 maps_client "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:3001->3000/tcp, :::3001->3000/tcp web-app
318dff5311a2 maps_web "bash /my-app/entryp…" 2 minutes ago Up 2 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp maps_web_1
b4a6914cc67a postgres:10.5 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:5105->5432/tcp, :::5105->5432/tcp maps_postgres_1
I would like to exec into my docker container using the readable image name, so I tried this
$ docker exec -it maps_web sh
Error: No such container: maps_web
What's the proper way to exec into docker using the image name (as opposed to the container ID)?
maps_web. Problem solved without writing custom shell scripts.docker-compose exec webwill use the Compose service name without needing to manually assign a container name.