Concepts de Base
1. Exercice A
1
docker run ubuntu echo "Hello, Docker"Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
ff65ddf9395b: Pull complete
Digest: sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5
Status: Downloaded newer image for ubuntu:latest
Hello, Docker2. Exercice B
1
nano main.pyfrom datetime import datetime
now = datetime.now()
print("Date et heure actuelles :", now)2
nano DockerfileFROM alpine
RUN apk update && apk add python3
COPY . /app
WORKDIR /app
CMD ["python3","main.py"]3
docker image build -t exercice-b:v0.1 .[+] Building 0.1s (9/9) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 134B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/4] FROM docker.io/library/alpine:latest 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 160B 0.0s
=> CACHED [2/4] RUN apk update && apk add python3 0.0s
=> [3/4] COPY . /app 0.0s
=> [4/4] WORKDIR /app 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:e4642afea15d72f269a711c273b531903dfb0f48e2591f4520e506bd4ff32f3d 0.0s
=> => naming to docker.io/library/exercice-b:v0.2 4
docker container run exercice-b:v0.1Date et heure actuelles : 2024-11-08 15:30:47.4154513. Exercice C

Last updated