Questions tagged [dockerfile]

For questions about Dockerfiles - text files containing instructions to build Docker container images.

From Dockerfile reference:

Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

132 questions
35
votes
4 answers

How to remove directories and files in another layer using Docker?

Why this question? The reason for posting this Q&A is that sometimes certain software is required to compile software in a docker image. Once compiled, these packages are superfluous and should be removed in order to reduce the image size. In some…
030
  • 13,235
  • 16
  • 74
  • 173
9
votes
1 answer

What is the difference between using brackets (`[` `]`) and just specifying the command in the CMD option in Dockerfiles?

Why does CMD ["mysqld"] result in: db_1 | 2017-05-14T16:34:11.829163Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 1 ... db_1 | 2017-05-14T16:34:11.833159Z 0 [Note] InnoDB: PUNCH HOLE support available db_1 | 2017-05-14T16:34:11.833190Z…
030
  • 13,235
  • 16
  • 74
  • 173
6
votes
1 answer

COPY and ZIP files in Dockerfile

Using a COPY statement creates a new image layer, right? COPY files/foo.zip /tmp/ Now, to save space I could take the ADD statement... for a GZ arhive. But ADD does not support automatic extraction of ZIP files. So the foo.zip will be dangling…
Ta Mu
  • 6,772
  • 5
  • 39
  • 82
3
votes
2 answers

What is the difference between RUN and CMD in a Dockerfile?

I am going to change my permission of files to 600. The following command works perfectly. RUN /bin/bash -c 'chmod 600 /root/.ssh/config' But this one failed CMD /bin/bash -c 'chmod 600 /root/.ssh/config' In the beginning, I thought the shell…
rj487
  • 143
  • 1
  • 6
3
votes
2 answers

Why can this ENV not be found when it is defined in one layer using a Dockerfile?

When the following Dockerfile: ENV A=123 \ B=$A RUN echo $B is run, it results in: Step 2/2 : RUN echo $B ---> Running in x ---> y Removing intermediate container z When two ENV layers are defined: ENV A=123 ENV B=$A it works: Step 2/2 :…
030
  • 13,235
  • 16
  • 74
  • 173
2
votes
1 answer

Dockerfile parse error line 5: unknown instruction: -ESSENTIAL

this is my dockerfile ; FROM ubuntu:16.04 MAINTAINER James Turnbull "james@example.com" ENV REFRESHED_AT 2016-06-01 RUN apt-get update -yqq; apt-get -yqq install ruby ruby-dev build -essential redis-tools RUN gem install --no-rdoc --no-ri…
theSeeker
  • 123
  • 1
  • 3
0
votes
1 answer

cannot import OpenCV in a Docker container in Raspberry Pi

I am trying to build a Docker container in Raspbian 10. FROM python:3.5-buster RUN apt-get update RUN apt-get install apt-utils -y RUN apt-get install python-opencv -y RUN apt-get install python3-opencv -y COPY a.py / CMD ["python3", "a.py"] a.py…
wannik
  • 101
  • 2