entrypoint docker code example

Example 1: debian docker

# Install docker
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install -y docker-ce

# Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Example 2: CMD or Entrypoint in Docker

FROM ubuntu:trusty
CMD ["/bin/ping","localhost"]

Example 3: CMD or Entrypoint in Docker

$ docker run -d demo
15bfcddb11b5cde0e230246f45ba6eeb1e6f56edb38a91626ab9c478408cb615

$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED
15bfcddb4312 demo:latest "/bin/sh -c 'ping localhost'" 2 seconds ago

Example 4: dockerfile example

FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py

Example 5: dockerfile env variabes

FROM busybox
ENV foo /bar
WORKDIR ${foo}   # WORKDIR /bar
ADD . $foo       # ADD . /bar
COPY \$foo /quux # COPY $foo /quux

Example 6: dockerfile run app cmd

RUN apt-get install python3
CMD echo "Hello world"
ENTRYPOINT echo "Hello world"

Tags:

Misc Example