Création_d_une_image_Docker_Alpine_pour_NodeJs_et_Python__french_

Création d’une image Docker Alpine pour NodeJs et Python

Ici, nous allons créer une image Docker Alpine, donc particulièrement petite, intégrant à la fois NodeJS et Python.

Créer un fichier Dockerfile :

cat <<EOF> Dockerfile
FROM node:8-alpine
RUN apk add --update --no-cache \
    bash \
    python \
    py-pip \
    groff \
    jq \
    zip \
    curl \
    git \
    ca-certificates && \
    apk -v --purge del py-pip
EOF

Créer une image alpine-nodejs-python :

docker build -t alpine-nodejs-python .
Sending build context to Docker daemon  28.06MB
Step 1/2 : FROM node:8-alpine
8-alpine: Pulling from library/node

cf9c0882: Pulling fs layer 
cf0467ca: Pulling fs layer 
402f98da: Pulling fs layer 
Digest: sha256:38f7bf07ffd72ac612ec8c829cb20ad416518dbb679768d7733c93175453f4d4
Status: Downloaded newer image for node:8-alpine
 ---> 2b8fcdc6230a
Step 2/2 : RUN apk add --update --no-cache     bash     python     py-pip     groff     jq     zip     curl     git     ca-certificates &&     apk -v --purge del py-pip
 ---> Running in 98f8ec09cd05
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/23) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(2/23) Installing ncurses-libs (6.1_p20200118-r4)
(3/23) Installing readline (8.0.1-r0)
(4/23) Installing bash (5.0.11-r1)
Executing bash-5.0.11-r1.post-install
(5/23) Installing ca-certificates (20191127-r2)
(6/23) Installing nghttp2-libs (1.40.0-r1)
(7/23) Installing libcurl (7.67.0-r1)
(8/23) Installing curl (7.67.0-r1)
(9/23) Installing expat (2.2.9-r1)
(10/23) Installing pcre2 (10.34-r1)
(11/23) Installing git (2.24.3-r0)
(12/23) Installing groff (1.22.4-r0)
(13/23) Installing oniguruma (6.9.4-r1)
(14/23) Installing jq (1.6-r0)
(15/23) Installing libbz2 (1.0.8-r1)
(16/23) Installing libffi (3.2.1-r6)
(17/23) Installing gdbm (1.13-r1)
(18/23) Installing sqlite-libs (3.30.1-r2)
(19/23) Installing python2 (2.7.18-r0)
(20/23) Installing py-setuptools (42.0.2-r0)
(21/23) Installing py2-pip (18.1-r0)
(22/23) Installing unzip (6.0-r6)
(23/23) Installing zip (3.0-r7)
Executing busybox-1.31.1-r8.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 88 MiB in 39 packages
The following packages will be REMOVED:
  py2-pip py-setuptools
After this operation, 12 MiB of disk space will be freed.
(1/2) Purging py2-pip (18.1-r0)
WARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory
(2/2) Purging py-setuptools (42.0.2-r0)
Executing busybox-1.31.1-r8.trigger
OK: 37 packages, 203 dirs, 3366 files, 76 MiB
Removing intermediate container 98f8ec09cd05
 ---> 411dde1b8081
Successfully built 411dde1b8081
Successfully tagged alpine-nodejs-python:latest

Créer un conteneur et vérifier :

  • que NodeJS est correctement installé :
docker run --rm alpine-nodejs-python node --version
v8.17.0
  • que Python est correctement installé :
docker run --rm alpine-nodejs-python python --version
Python 2.7.18

Création_d_une_image_Docker_Alpine_pour_NodeJs_et_Python__english_

Creation of an Alpine Docker image for NodeJs and Python

Here we will create an Alpine Docker image, therefore particularly small, integrating both NodeJS and Python.

Create a Dockerfile:

cat <<EOF> Dockerfile
FROM node:8-alpine
RUN apk add --update --no-cache \
    bash \
    python \
    py-pip \
    groff \
    jq \
    zip \
    curl \
    git \
    ca-certificates && \
    apk -v --purge del py-pip
EOF

Create an image alpine-nodejs-python:

docker build -t alpine-nodejs-python .
Sending build context to Docker daemon  28.06MB
Step 1/2 : FROM node:8-alpine
8-alpine: Pulling from library/node

cf9c0882: Pulling fs layer 
cf0467ca: Pulling fs layer 
402f98da: Pulling fs layer 
Digest: sha256:38f7bf07ffd72ac612ec8c829cb20ad416518dbb679768d7733c93175453f4d4
Status: Downloaded newer image for node:8-alpine
 ---> 2b8fcdc6230a
Step 2/2 : RUN apk add --update --no-cache     bash     python     py-pip     groff     jq     zip     curl     git     ca-certificates &&     apk -v --purge del py-pip
 ---> Running in 98f8ec09cd05
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/23) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(2/23) Installing ncurses-libs (6.1_p20200118-r4)
(3/23) Installing readline (8.0.1-r0)
(4/23) Installing bash (5.0.11-r1)
Executing bash-5.0.11-r1.post-install
(5/23) Installing ca-certificates (20191127-r2)
(6/23) Installing nghttp2-libs (1.40.0-r1)
(7/23) Installing libcurl (7.67.0-r1)
(8/23) Installing curl (7.67.0-r1)
(9/23) Installing expat (2.2.9-r1)
(10/23) Installing pcre2 (10.34-r1)
(11/23) Installing git (2.24.3-r0)
(12/23) Installing groff (1.22.4-r0)
(13/23) Installing oniguruma (6.9.4-r1)
(14/23) Installing jq (1.6-r0)
(15/23) Installing libbz2 (1.0.8-r1)
(16/23) Installing libffi (3.2.1-r6)
(17/23) Installing gdbm (1.13-r1)
(18/23) Installing sqlite-libs (3.30.1-r2)
(19/23) Installing python2 (2.7.18-r0)
(20/23) Installing py-setuptools (42.0.2-r0)
(21/23) Installing py2-pip (18.1-r0)
(22/23) Installing unzip (6.0-r6)
(23/23) Installing zip (3.0-r7)
Executing busybox-1.31.1-r8.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 88 MiB in 39 packages
The following packages will be REMOVED:
  py2-pip py-setuptools
After this operation, 12 MiB of disk space will be freed.
(1/2) Purging py2-pip (18.1-r0)
WARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory
(2/2) Purging py-setuptools (42.0.2-r0)
Executing busybox-1.31.1-r8.trigger
OK: 37 packages, 203 dirs, 3366 files, 76 MiB
Removing intermediate container 98f8ec09cd05
 ---> 411dde1b8081
Successfully built 411dde1b8081
Successfully tagged alpine-nodejs-python:latest

Create a container and check :

  • that NodeJS is correctly installed:
docker run --rm alpine-nodejs-python node --version
v8.17.0
  • that Python is correctly installed:
docker run --rm alpine-nodejs-python python --version
Python 2.7.18
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×