FROM ubuntu:20.04
ENV TZ=America/Los_Angeles
RUN mkdir -p /home/my_user
COPY ./files/in_home /home/my_user/in_home
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y
RUN apt install -y nginx php
COPY ./files/nginx/my.conf /etc/nginx/sites-available/my.conf
RUN ln -s /etc/nginx/sites-available/my.conf /etc/nginx/sites-enabled/my.conf
CMD ["nginx", "-g", "daemon off;"]
Here is the context.
.
├── Dockerfile
└── files
├── in_home(dir)
└── nginx
└── my.conf
Exec the commands below and run
docker build -t atlex/test:v1 ./
docker run --name="DockerfileTest" -d -p 50001:80 atlex/test:v1
FROM ubuntu:20.04
: Build the docker image from Ubuntu 20.04 image.ENV TZ=America/Los_Angeles
: Set environment variable TimeZone as America/Los_Angeles
.RUN mkdir -p /home/my_user
: Run command mkdir -p /home/my_user
.COPY ./files/in_home /home/my_user/in_home
: Copy local Directory ./files/in_home
to the container (image) as name /home/my_user/in_home
.ARG DEBIAN_FRONTEND=noninteractive
: Well known problem in Ubuntu docker image2.https://nickjanetakis.com/blog/docker-tip-2-the-difference-between-copy-and-add-in-a-dockerile
First, you can use a URL instead of a local file / directory. Secondly, you can extract a tar file from the source directly into the destination. … If you’re copying in local files to your Docker image, always use COPY because it’s more explicit.
https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
WORKDIR
: kind of cd