Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 1.14 KB

docker.md

File metadata and controls

59 lines (38 loc) · 1.14 KB

Given the docker file,

  • Build a container image with the name nginxer and tag 3.0.
  • Export the built container image in OCI-format and store in at nginxer-3.0.tar
  • Run container from image nginxer:3.0 with name nginxer-go expsoing port 80
FROM nginx:alpine
CMD ["nginx", "-g", "daemon off;"]

show

docker build . -t nginxer:3.0
docker save nginxer:3.0 -o nginxer-3.0.tar
docker run --name nginxer-go -p 80:80 nginxer:3.0


Given the docker file which creates an alpine container exposing port 80. Apply 2 best practices to improve security of the image.

FROM alpine:3.12
RUN adduser -D myuser && chown -R myuser /myapp-data
USER root
ENTRYPOINT ["/myapp"]
EXPOSE 80 8080 22

show

FROM alpine:3.12
RUN adduser -D myuser && chown -R myuser /myapp-data
USER myuser # Avoid unnecessary privileges - run as a custom user.
ENTRYPOINT ["/myapp"]
EXPOSE 80 # Exposed ports - Expose only neccesary port