This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Below is used for representation purpose and is not in any way a working Dockerfile. | |
### Dockerfile - I | |
FROM ubuntu:18.04 | |
ENV APP_USER=TEST | |
ENV APP_PORT=8080 | |
RUN apt-get update | |
RUN apt-get install -y pkg1 pkg2 pkg3 | |
RUN mkdir -p /usr/src/test-dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Below is used for representation purpose and is not in any way a working Dockerfile. | |
### Build the artifact using Dockerfile.build | |
docker build -t artifact-build -f Dockerfile.build | |
### Create the container using the image to obtain artifact | |
docker create --name artifact-container artifact-build | |
### Copy the artifact from container to host machine | |
docker cp artifact-conatiner:<src_path_of_artifact> <host_machine_path> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Below is used for representation purpose and is not in any way a working Dockerfile. | |
FROM alpine:latest | |
RUN apk update && apk add --no-cache gcc musl-dev | |
COPY <prg>.c . | |
RUN gcc -static -o <prg> <prg>.c | |
FROM alpine:latest | |
COPY --from=0 <prg> /usr/bin/<prg> | |
ENTRYPOINT ["/usr/bin/<prg>"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Dockerfile, with RUN uncombined | |
FROM ubuntu:16.04 | |
ADD app.zip . # App of 200 MB | |
RUN chmod 777 app.zip | |
RUN rm -rf app.zip | |
## Dockerfile, with RUN combined | |
FROM ubuntu:16.04 | |
ADD app.zip . # App of 200 MB | |
RUN chmod 777 app.zip && rm -rf app.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build -t app-unsquashed . | |
$ docker history app-unsquashed | |
IMAGE CREATED CREATED BY SIZE COMMENT | |
7ee5b606949f 1 hour ago /bin/sh -c rm -rf app.zip 0B | |
7df1dc446bd0 2 hour ago /bin/sh -c chmod 777 app.zip 210MB | |
71530d33b38b 2 huor ago /bin/sh -c #(nop) ADD file:b12845ba907bbbc42… 210MB | |
b9e15a5d1e1a 8 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B | |
<missing> 8 days ago /bin/sh -c mkdir -p /run/systemd && echo 'do… 7B | |
<missing> 8 days ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$… 2.76kB | |
<missing> 8 days ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build --squash -t app-squashed . | |
$ docker history app-squashed | |
IMAGE CREATED CREATED BY SIZE COMMENT | |
c3f98f9241fc 2 hours ago 0B merge sha256:7ee5b606949f15cdfc790a44b49ea83b2ae7c8be808eedfb74234b47a50e66f1 to sha256:b9e15a5d1e1a11a69061b1dc2e3641805a2dc54e1338faf7f87f4c2c21ed3e6a | |
<missing> 2 hours ago /bin/sh -c rm -rf app.zip 0B | |
<missing> 2 hours ago /bin/sh -c chmod 777 app.zip 0B | |
<missing> 2 hours ago /bin/sh -c #(nop) ADD file:b12845ba907bbbc42… 0B | |
<missing> 8 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B | |
<missing> 8 days ago /bin/sh -c mkdir -p /run/systemd && echo 'do… 7B | |
<missing> 8 days ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$… 2.76kB |