Entrypoint Command

In this lesson, we will begin working with the ENTRYPOINT instruction. Though ENTRYPOINT functions very similarly to CMD it's behaviors are very different.

ENTRYPOINT allows us to configure a container that will run as an executable. We can override all elements specified using CMD. Using the docker run --entrypoint flag will override the ENTRYPOINT instruction.

Step 1: Setup your environment:

mkdir entrypoint
cd entrypoint

Step 2: Clone the image:

git clone https://github.com/nishanthkumarpathi/content-weather-app.git src

Step 3: Create the Dockerfile:

vi Dockerfile

Step 3: Create an image for the weather-app

Dockerfile contents:

FROM node
LABEL org.label-schema.version=v1.1
ENV NODE_ENV="production"
ENV PORT 3001

RUN mkdir -p /var/node
ADD src/ /var/node/
WORKDIR /var/node
RUN npm install
EXPOSE $PORT
ENTRYPOINT ./bin/www

Step 4: Build the image:

docker image build -t nishanthkp/weather-app:v4 .

Step 5: Deploy the weather-app:

docker container run -d --name weather-app4 nishanthkp/weather-app:v4

Step 6: Inspect weather-app4:

docker container inspect weather-app4 | grep Cmd
docker container inspect weather-app-nonroot
docker container inspect weather-app4

Step 7: Create the weather-app container:

docker container run -d --name weather-app5 -p 8083:3001 nishanthkp/weather-app:v4 echo "Hello World"

Step 8: Inspect weather-app5:

docker container inspect weather-app5

Step 9: Create the volumes for Prometheus:

docker volume create prometheus
docker volume create prometheus_data
sudo chown -R nfsnobody:nfsnobody /var/lib/docker/volumes/prometheus/
sudo chown -R nfsnobody:nfsnobody /var/lib/docker/volumes/prometheus_data/

Step 10: Create the Prometheus container:

docker run --name prometheus -d -p 8084:9090 \
  -v prometheus:/etc/prometheus \
  -v prometheus_data:/prometheus/data \
  prom/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/prometheus/data

Step 11: Inspect Prometheus:

docker container inspect prometheus

Prometheus Dockerfile

https://github.com/prometheus/prometheus/blob/master/Dockerfile

Last updated