docker version
Client: Docker Engine - Community
Cloud integration: 1.0.9
Version: 20.10.5
API version: 1.41
Go version: go1.13.15
Git commit: 55c4c88
Built: Tue Mar 2 20:13:00 2021
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.5
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 363e9a8
Built: Tue Mar 2 20:15:47 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker build -t test .
[+] Building 110.4s (12/12) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 561B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:12.16-alpine 1.3s
=> [internal] load build context 3.2s
=> => transferring context: 87.42MB 3.2s
=> [1/7] FROM docker.io/library/node:12.16-alpine@sha256:84f5c9090cc741421b2376b2393e7d5fa2f 0.0s
=> CACHED [2/7] WORKDIR /src/auth-api 0.0s
=> CACHED [3/7] RUN apk add jq --no-cache && apk update && apk add py-pip --no-cache && pip 0.0s
=> [4/7] COPY . /src/auth-api 0.4s
=> [5/7] RUN chown -R node:node /src/ 0.7s
=> [6/7] RUN chmod +x /src/auth-api/docker-entrypoint.sh 0.5s
=> [7/7] RUN npm i 64.1s
=> exporting to image 40.1s
=> => exporting layers 40.0s
=> => writing image sha256:44454a3901a9b381fcb169bf75fd4c32f24ceabaef243a965678678d8075ab64 0.0s
=> => naming to docker.io/library/test 0.0s
docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
test latest 1ba7a74a0656 28 seconds ago 492MB
mysql 5.7.32 1b12f2e9257b 4 months ago 448MB
dlo/step-api latest caf1ac2690d9 23 months ago 527MB
mongo latest a3abd47e8d61 2 years ago 394MB
node 8-alpine ee8b4f3c67fa 2 years ago 66.3MB
docker run test
This will use the CMD specified inside a dockerfile.
The ENTRYPOINT instruction can also be used in combination with a helper script, e.g even when starting it may require more than one step.
Example dockerfile below:
FROM node:12.16-alpine
ARG NPM_TOKEN
WORKDIR /src/auth-api
ENV PORT=8080
EXPOSE 8080
RUN apk add jq --no-cache && apk update && apk add py-pip --no-cache && pip install awscli
COPY . /src/auth-api
RUN chown -R node:node /src/
RUN chmod +x /src/auth-api/docker-entrypoint.sh
USER node
RUN npm i
ENTRYPOINT ["/src/auth-api/docker-entrypoint.sh"]
CMD [\
"node",\
"-r", "newrelic",\
"-r", "source-map-support/register",\
"-r", "express-async-errors",\
"--max-http-header-size", "16000",\
"main.js"\
]
docker run -it test sh
NEW_RELIC_LICENSE_KEY not set.
New Relic disabled.
/src/auth-api $ pwd
/src/auth-api
/src/auth-api $ ls -l
total 85560
-rw-r--r-- 1 node node 494 Mar 19 14:17 addEmail.ts
-rw-r--r-- 1 node node 841 Mar 19 14:17 compile.ts
-rwxr-xr-x 1 node node 440 Mar 19 14:17 docker-entrypoint.sh
-rw-r--r-- 1 node node 517 Mar 19 14:17 dockerfile
-rw-r--r-- 1 node node 725 Mar 19 14:17 forgotPassword.ts
drwxr-xr-x 1 node node 4096 Mar 19 14:18 html
-rw-r--r-- 1 node node 1124 Mar 19 14:17 inviteEmail.ts
-rw-r--r-- 1 node node 384 Mar 4 14:56 lastGenerated-verify-email.json
-rw-r--r-- 1 node node 136 Mar 4 14:56 lastSelfSignup.json
-rw-r--r-- 1 node node 2796743 Mar 19 14:17 main.js
-rw-r--r-- 1 node node 6925578 Mar 19 14:17 main.js.map
drwxr-xr-x 395 node node 16384 Mar 19 14:19 node_modules
-rw-r--r-- 1 node node 162963 Mar 19 14:19 package-lock.json
-rw-r--r-- 1 node node 2623 Mar 19 14:19 package.json
-rw-r--r-- 1 node node 23676032 Mar 19 14:17 query-engine-darwin
-rw-r--r-- 1 node node 28312016 Mar 19 14:17 query-engine-linux-musl
-rw-r--r-- 1 node node 25655648 Mar 19 14:17 query-engine-rhel-openssl-1.0.x
-rw-r--r-- 1 node node 3851 Mar 19 14:17 schema.prisma
-rw-r--r-- 1 node node 382 Mar 19 14:17 utils.ts
/src/auth-api $
docker-compose up
Starting data_db_1 ... done
Attaching to data_db_1
db_1 | 2021-03-19 14:31:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.32-1debian10 started.
db_1 | 2021-03-19 14:31:14+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1 | 2021-03-19 14:31:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.32-1debian10 started.
db_1 | 2021-03-19 14:31:15+00:00 [Note] [Entrypoint]: Initializing database files
db_1 | 2021-03-19T14:31:15.075700Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1 | 2021-03-19T14:31:15.098256Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
db_1 | 2021-03-19T14:31:18.297348Z 0 [Warning] InnoDB: New log files created, LSN=45790
db_1 | 2021-03-19T14:31:19.267544Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
db_1 | 2021-03-19T14:31:19.418249Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c53d0b6c-88bf-11eb-bece-0242ac130002.
db_1 | 2021-03-19T14:31:19.434946Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db_1 | 2021-03-19T14:31:24.002366Z 0 [Warning] CA certificate ca.pem is self signed.
db_1 | 2021-03-19T14:31:24.948274Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
^CGracefully stopping... (press Ctrl+C again to force)
Stopping data_db_1 ...
Killing data_db_1 ... done