title: How do I exec into a docker container using its image name (as opposed to container ID)?
body: <p>I'm using the following version of Docker</p>
  <pre><code>$ docker -v
  Docker version 20.10.7, build f0df350
  </code></pre>
  <p>When I start my containers using &quot;docker-compose up&quot;, I can see them all come up with</p>
  <pre><code>CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                                       NAMES
  29e94e032fbb   maps_apache     &quot;httpd-foreground&quot;       2 minutes ago   Up 2 minutes   0.0.0.0:9090-&gt;80/tcp, :::9090-&gt;80/tcp       maps_apache_1
  13a8f2f037e4   maps_client     &quot;docker-entrypoint.s…&quot;   2 minutes ago   Up 2 minutes   0.0.0.0:3001-&gt;3000/tcp, :::3001-&gt;3000/tcp   web-app
  318dff5311a2   maps_web        &quot;bash /my-app/entryp…&quot;   2 minutes ago   Up 2 minutes   0.0.0.0:8000-&gt;8000/tcp, :::8000-&gt;8000/tcp   maps_web_1
  b4a6914cc67a   postgres:10.5   &quot;docker-entrypoint.s…&quot;   2 minutes ago   Up 2 minutes   0.0.0.0:5105-&gt;5432/tcp, :::5105-&gt;5432/tcp   maps_postgres_1
  </code></pre>
  <p>I would like to exec into my docker container using the readable image name, so I tried this</p>
  <pre><code>$ docker exec -it maps_web sh
  Error: No such container: maps_web
  </code></pre>
  <p>What's the proper way to exec into docker using the image name (as opposed to the container ID)?</p>