This is an old revision of the document!


docker windows

installation de docker desktop sur windows 11

references

Astuce groupe docker

apres l'installation initial, impossible de se connecter / lancer Docker destop , il faut que notre user non privilegier appartienne au croupe docker ! apres ça il faut fermer la session et la relancer , autrement on n'est tj pas dans le groupe docker .

https://forums.docker.com/t/error-when-trying-to-run-windows-containers-docker-client-must-be-run-with-elevated-privileges/136619/2 https://serverfault.com/questions/532106/get-list-of-ad-groups-a-user-is-a-member-of

docker terminal /shell

list & get images

C:\Users\jehan>docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

C:\Users\jehan>docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

C:\Users\jehan>docker pull nginx:1.27.2
1.27.2: Pulling from library/nginx
2d429b9e73a6: Pull complete
9b1039c85176: Pull complete
9ad567d3b8a2: Pull complete
773c63cd62e4: Pull complete
1d2712910bdf: Pull complete
4b0adc47c460: Pull complete
171eebbdf235: Pull complete
Digest: sha256:bc5eac5eafc581aeda3008b4b1f07ebba230de2f27d47767129a6a905c84f470
Status: Downloaded newer image for nginx:1.27.2
docker.io/library/nginx:1.27.2

C:\Users\jehan>docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        1.27.2    60c8a892f36f   5 weeks ago   192MB

run images

running an image creates a instance of the image = container

C:\Users\jehan>docker run nginx:1.27.2
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/11/12 14:38:28 [notice] 1#1: using the "epoll" event method
2024/11/12 14:38:28 [notice] 1#1: nginx/1.27.2
2024/11/12 14:38:28 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/12 14:38:28 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/11/12 14:38:28 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/12 14:38:28 [notice] 1#1: start worker processes
2024/11/12 14:38:28 [notice] 1#1: start worker process 29
2024/11/12 14:38:28 [notice] 1#1: start worker process 30
2024/11/12 14:38:28 [notice] 1#1: start worker process 31
2024/11/12 14:38:28 [notice] 1#1: start worker process 32
2024/11/12 14:38:28 [notice] 1#1: start worker process 33
2024/11/12 14:38:28 [notice] 1#1: start worker process 34
2024/11/12 14:38:28 [notice] 1#1: start worker process 35
2024/11/12 14:38:28 [notice] 1#1: start worker process 36
2024/11/12 14:38:28 [notice] 1#1: start worker process 37
2024/11/12 14:38:28 [notice] 1#1: start worker process 38
2024/11/12 14:38:28 [notice] 1#1: start worker process 39
2024/11/12 14:38:28 [notice] 1#1: start worker process 40

dans un autre terminal 

C:\Users\jehan>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
3c24edd9cc6d   nginx:1.27.2   "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes   80/tcp    xenodochial_babbage

run ct as daemon

option -d

C:\Users\jehan>docker run -d nginx:1.27.2
8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831

C:\Users\jehan>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS     NAMES
8aa18cfb6e51   nginx:1.27.2   "/docker-entrypoint.…"   54 seconds ago   Up 53 seconds   80/tcp    trusting_napier

get log in daemon mode

docker logs ct-ID

C:\Users\jehan>docker logs 8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/11/12 14:42:30 [notice] 1#1: using the "epoll" event method
2024/11/12 14:42:30 [notice] 1#1: nginx/1.27.2
2024/11/12 14:42:30 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/12 14:42:30 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/11/12 14:42:30 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/12 14:42:30 [notice] 1#1: start worker processes

Network, expose port

by default the 80 port is only exposed inside the CT, we have to export/expose it outside the CT by binding it to an external port, option -p 8080:80 (a privilege dialog might open to allow firewall access)

C:\Users\jehan>docker stop 8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831
8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831

C:\Users\jehan>docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

C:\Users\jehan>docker run -d -p 8080:80 nginx:1.27.2
70a30ce86f2fd3d8556e731487b9d0505dd9e54bc1de6ee7040889b0ca785447

http://localhost:8080/

list previous instances

C:\Users\jehan>docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                      PORTS                  NAMES
70a30ce86f2f   nginx:1.27.2   "/docker-entrypoint.…"   7 minutes ago    Up 7 minutes                0.0.0.0:8080->80/tcp   competent_austin
8aa18cfb6e51   nginx:1.27.2   "/docker-entrypoint.…"   16 minutes ago   Exited (0) 8 minutes ago                           trusting_napier
3c24edd9cc6d   nginx:1.27.2   "/docker-entrypoint.…"   20 minutes ago   Exited (0) 16 minutes ago                          xenodochial_babbage
C:\Users\jehan>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                  NAMES
70a30ce86f2f   nginx:1.27.2   "/docker-entrypoint.…"   9 minutes ago   Up 9 minutes   0.0.0.0:8080->80/tcp   competent_austin

C:\Users\jehan>docker stop 70a30ce86f2f
70a30ce86f2f

C:\Users\jehan>
C:\Users\jehan>docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

C:\Users\jehan>docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                      PORTS     NAMES
70a30ce86f2f   nginx:1.27.2   "/docker-entrypoint.…"   9 minutes ago    Exited (0) 5 seconds ago              competent_austin
8aa18cfb6e51   nginx:1.27.2   "/docker-entrypoint.…"   17 minutes ago   Exited (0) 10 minutes ago             trusting_napier
3c24edd9cc6d   nginx:1.27.2   "/docker-entrypoint.…"   21 minutes ago   Exited (0) 18 minutes ago             xenodochial_babbage

it is more convenient to name CT instead of using random IDs, option –name

C:\Users\jehan>docker run -d --name webApp -p 8080:80 nginx:1.27.2
fb93da95c41f639d38a08d06e39ff14da2144e1f3baa1a33d9fa7099a1c0c4cd

C:\Users\jehan>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                  NAMES
fb93da95c41f   nginx:1.27.2   "/docker-entrypoint.…"   5 seconds ago   Up 4 seconds   0.0.0.0:8080->80/tcp   webApp

own images

get a source code example on a nodeJS app from Nana

jehan@G10JP24 MINGW64 ~/Documents/Progs-JP/docker-tuto-nana
$ git clone https://github.com/nomsynonso/techworld-js-docker-demo-app.git
Cloning into 'techworld-js-docker-demo-app'...
remote: Enumerating objects: 52, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 52 (delta 16), reused 15 (delta 15), pack-reused 31 (from 1)
Receiving objects: 100% (52/52), 5.80 MiB | 3.42 MiB/s, done.
Resolving deltas: 100% (21/21), done.