Linked Questions
116 questions linked to/from What is the difference between CMD and ENTRYPOINT in a Dockerfile?
1
vote
1
answer
4k
views
Why both CMD and entrypoint defined in some images? [duplicate]
I have seen some images that based on the inspect have both CMD and ENTRYPOINT set.
What is the idea of this? What use cases are served when both are set?
3138
votes
17
answers
1.1m
views
What is the difference between the 'COPY' and 'ADD' commands in a Dockerfile?
What is the difference between the COPY and ADD commands in a Dockerfile, and when would I use one over the other?
COPY <src> <dest>
The COPY instruction will copy new files from <...
48
votes
2
answers
64k
views
How can I start spring boot application in docker with profile?
I have a simple spring-boot project:
-resources
-application.yaml
-application-test.yaml
And I have this Dockerfile:
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ADD micro-boot.jar micro-boot.jar
...
53
votes
3
answers
48k
views
Default Docker entrypoint
I am creating an image from another image that set a specific entrypoint. However I want my image to have default one. How do I reset the ENTRYPOINT?
I tried the following Dockerfile:
FROM some-...
67
votes
2
answers
32k
views
Differences Between Dockerfile Instructions in Shell and Exec Form
What is the difference between shell and exec form for
CMD:
CMD python my_script.py arg
vs.
CMD ["python", "my_script.py", "arg"]
ENTRYPOINT:
ENTRYPOINT ./bin/main
vs.
...
33
votes
3
answers
30k
views
Execute a script before CMD
As per Docker documentation:
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
I wish to execute a simple bash script(which ...
39
votes
1
answer
85k
views
Starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown
I want to understand how CMD and ENTRYPOINT works. So, I just created a very simple Dockerfile
FROM scratch
CMD echo "Hello First"
ENTRYPOINT echo "Hello second"
Then I build image of this :
...
24
votes
3
answers
29k
views
Is CMD or ENTRYPOINT necessary to mention in Dockerfile?
I have read the docs about CMD and ENTRYPOINT
https://docs.docker.com/engine/reference/builder/#entrypoint
Here, they have mentioned in the table that "NO CMD and NO ENTYRPOINT is not allowed&...
26
votes
3
answers
22k
views
Jenkins docker container always adds cat command
I am creating Jenkins pipeline for running terraform on a Docker container.
Here is my pipeline script.
pipeline {
agent {
docker {
image 'hashicorp/terraform:full'
...
23
votes
4
answers
18k
views
Does 'docker start' execute the CMD command?
Let's say a docker container has been run with docker run and then stopped with docker stop. Will the CMD command be executed after a docker start?
22
votes
3
answers
100k
views
entrypoint: "entrypoint.sh" - docker compose
There is no such file by name entrypoint.sh in my workspace.
But below instruction in docker-compose.yml is referring it:
builder:
build: ../../
dockerfile: docker/dev/Dockerfile
volumes:
...
31
votes
2
answers
24k
views
Docker input/output outside the container
I created a docker container with a python script. The python script takes an input file, does some processing and saves output file at some specified location.
docker run /app/script.py --input /...
11
votes
3
answers
44k
views
Passing parameters to Docker container
I create a container docker. Which should give the following:
docker run --rm container1
> Hello World!
docker run --rm container1 Bob
> Hello Bob!
My Dockerfile:
FROM ubuntu:14.04
ENTRYPOINT ...
16
votes
1
answer
34k
views
Why do some docker images require a command when run?
I find when using docker run I sometimes don't need to add a "command", while sometimes a "command" is a must. E.g. when running the ubuntu image a command isn't required:
# docker run ubuntu
#
...
5
votes
2
answers
33k
views
running netcat inside docker container
I have created docker images using the below Dockerfile.
FROM ubuntu
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
net-tools \
&& apt-get clean \...