title: With docker-compose, how do I keep a container running even if the "command" fails?
body: <p>I’m using docker 20.10.12 on Mac Big Sur.  I have the following snippet in my docker-compose file</p>
  <pre><code>  web:
      restart: &quot;no&quot;
      build: ../my-dir
      ports:
        - &quot;3000:3000&quot;
      expose:
        - '3000'
      command: /bin/sh -c &quot;foreman start -f myprocfile”
      volumes:
      - ../cfs-web/:/app
      depends_on:
        - db
  </code></pre>
  <p>The problem is if my “command” fails, the container dies and I’m unable to exec into it.  If I change restart to</p>
  <pre><code>Restart: “always”
  </code></pre>
  <p>The container continuously restarts and fails, but I’m still unable to exec in because it seems like the container is getting re-created each time.  Is there a way to keep the container up even if the command fails (so I can login and potentially run some other commands)?</p>