title: Access logs of a killed docker container
body: <p>I recently had to clean up my full disk because of space taken by past docker containers. So I assume that I can access logs of killed containers.</p>
  
  <p>For example I have the docker history of a container:</p>
  
  <pre><code>$ docker history xxx_app
  IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
  d7cfe17fc42a        56 minutes ago      /bin/sh -c #(nop)  EXPOSE 3000/tcp              0 B                 
  cd26ca1108f0        56 minutes ago      /bin/sh -c #(nop) COPY dir:8daa84a931569267ab   62.27 MB            
  6fa873fcc7bb        9 days ago          /bin/sh -c npm install &amp;&amp; npm cache clean       177.8 MB            
  67a23b0934d8        9 days ago          /bin/sh -c #(nop) COPY file:5dcb2a83410d0aa7f   1.529 kB            
  3b7197885c91        3 weeks ago         /bin/sh -c #(nop)  ENV NODE_ENV=                0 B                 
  79a447242ea5        3 weeks ago         /bin/sh -c #(nop)  ARG NODE_ENV                 0 B                 
  b1909b86ce39        3 weeks ago         /bin/sh -c #(nop)  CMD ["npm" "start"]          0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  ONBUILD COPY . /usr/src/ap   0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  ONBUILD RUN npm install &amp;&amp;   0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  ONBUILD COPY package.json    0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  ONBUILD ENV NODE_ENV $NODE   0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  ONBUILD ARG NODE_ENV         0 B                 
  &lt;missing&gt;           3 weeks ago         /bin/sh -c #(nop)  WORKDIR /usr/src/app         0 B                 
  ...
  </code></pre>
  
  <p>But I get an error when accessing logs:</p>
  
  <pre><code>docker logs 67a23b0934d8
  Error: No such container: 67a23b0934d8
  </code></pre>
  
  <p>Despite that, my disk's getting full by container images that were created, and I had to take action following <a href="https://lebkowski.name/docker-volumes/" rel="noreferrer">this article</a> to clean up about a month ago. So, can I access past logs?</p>
  
  <p>PS: I'm not very knowledgeable about docker, I took over a project. The way the containers are restarted after each code update is this:</p>
  
  <pre><code>docker-compose -f docker-compose-production.yaml down
  docker-compose -f docker-compose-production.yaml up -d --build
  </code></pre>