Dockerfile memo


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

Basic 2

FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
    curl \

Basic 3

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

Basic 4

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

Basic 5

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"]

Basic 6

FROM ubuntu:latest
ENV key1 value  //Set environment variables ENV<key name> <value>
ENV key2=value 

Basic 7

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

Dockerfile memo
Integer memo
docker memo
Lombok memo
Iterator memo
corretto memo
Java memo
AWS memo
About Dockerfile
[Note] Dockerfile
Dcokerfile memo
Ruby memo
Memo Stream
Spring retrospective memo
docker tutorial (memo)
java anything memo
primary key memo
Stream API memo
Docker operation memo
Eclipse trick memo
Java Silver memo
java, maven memo
JavaParser usage memo
Docker command memo
SpringBoot-JPA-Hibernate addictive memo
Kubernetes/container-related standardization memo
Java SE 7 memo
[Memo] docker summary
OpenJDK 11 installation memo
MySQL migration memo (1)
WatchService usage memo
PlantUML usage memo
java anything memo 2
Docker-compose command memo
e-Gov setting memo
[wip] Ruby memo
Maven3 error memo
Java specification memo
JUnit5 usage memo
Java pattern memo