How to write dockerfile Personal memo
FROM ubuntu:latest //Determining the base image: Describe first
RUN touch test //Customize. An image layer is created for each RUN
CMD ["/bin/bash"] //Specify the default command CMD described at the end in principle["command","Argument 1", "Argument 2"]
Minimize layers. (Minimize RUN ADD COPY) CMD does not create layers
FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
curl \
nginx
FROM ubuntu:latest
FROM ubuntu:latest
RUN mkdir /new_dir
COPY something /new_dir/ // COPY <src folder or file> <destination path>Copy files and folders in the docker context to a container
FROM ubuntu:latest
RUN mkdir /new_dir
ADD compressed.tar / // COPY <src folder or file> <destination path>Unzip the tar file or folder in the docker context and copy it to the container
FROM ubuntu:latest
RUN touch test
ENTRYPOINT ["ls"] //Unlike CMD, ENTRYPOINT cannot be overwritten during docker run. Also, write the option to CMD
CMD ["--help"]
FROM ubuntu:latest
ENV key1 value //Set environment variables ENV<key name> <value>
ENV key2=value
FROM ubuntu:latest
RUN mkdir sample_folder //I don't really need it
WORKDIR /sample_folder //Change the instruction execution directory
RUN touch sample_file
cd is the source of bugs
Recommended Posts