Open4
docker container
イメージの作成
- harl@macMini dev %
ls -l
total 0
drwxr-xr-x 3 sharl staff 96 9 15 01:34 deno
drwxr-xr-x 3 sharl staff 96 8 20 16:40 go
drwxr-xr-x 4 sharl staff 128 8 23 01:50 grpc
drwxr-xr-x 2 sharl staff 64 10 1 07:53 python
drwxr-xr-x 3 sharl staff 96 9 11 21:48 svelte
- sharl@macMini dev %
mkdir docker;cd docker
- sharl@macMini docker %
mkdir hello
- sharl@macMini docker %
vim ./hello/hello.sh
#!/bin/sh
set -eu -o pipefail
echo "Hello, World"
- sharl@macMini docker %
vim ./hello/Dockerfile
FROM busybox:1.35
COPY ./hello.sh /
RUN chmod u+x /hello.sh
ENTRYPOINT /hello.sh
- sharl@macMini docker %
docker build -t hello hello
- docker build -t 生成するイメージ名 Dockerfileがあるフォルダのパス
実行結果
[+] Building 4.4s (9/9) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 118B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/busybox:1.35 3.3s
=> [auth] library/busybox:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 87B 0.0s
=> [1/3] FROM docker.io/library/busybox:1.35@sha256:7ae8447f3a7f5bccaa765926f25fc038e425cf1b2be6748727bbea9a13102094 1.0s
=> => resolve docker.io/library/busybox:1.35@sha256:7ae8447f3a7f5bccaa765926f25fc038e425cf1b2be6748727bbea9a13102094 0.0s
=> => sha256:8efa25f4ef5cee067469977d319254414c5292cb3dc62e9f178df1465753a5e4 1.91MB / 1.91MB 0.9s
=> => sha256:7ae8447f3a7f5bccaa765926f25fc038e425cf1b2be6748727bbea9a13102094 2.29kB / 2.29kB 0.0s
=> => sha256:8cd9c953d2a64decb75ca46b4cf22f6e2e3cd3ea8ab1257236a0c29ed3f7d2c1 528B / 528B 0.0s
=> => sha256:cb300da5c300405b14faed616992ef14a76c344eb4d7cc318606f4937565a1d6 1.47kB / 1.47kB 0.0s
=> => extracting sha256:8efa25f4ef5cee067469977d319254414c5292cb3dc62e9f178df1465753a5e4 0.1s
=> [2/3] COPY ./hello.sh / 0.0s
=> [3/3] RUN chmod u+x /hello.sh 0.1s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:ed0de5516d2d5bf3a29ffc35d012f832e11200bc185aecdd167da93192e5ea3c 0.0s
=> => naming to docker.io/library/hello 0.0s
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
- sharl@macMini docker %
docker login -u teruroomuser
- Password:
himitsu
Login Succeeded
- sharl@macMini docker %
docker tag hello teruroomuser/hello:v1
- sharl@macMini docker %
docker push teruroomuser/hello:v1
実行結果
The push refers to repository [docker.io/teruroomuser/hello]
bc97656f038d: Pushed
db77520ca0aa: Pushed
115566417e3e: Mounted from library/busybox
v1: digest: sha256:2219c93fd64b74ab28fe659e8e2962faa46ad24684b9ac7353bfbb8a851d5807 size: 942
- sharl@macMini docker %
docker pull teruroomuser/hello:v1
実行結果
v1: Pulling from teruroom11/hello
Digest: sha256:2219c93fd64b74ab28fe659e8e2962faa46ad24684b9ac7353bfbb8a851d5807
Status: Image is up to date for teruroom11/hello:v1
docker.io/teruroom11/hello:v1
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview teruroom11/hello:v1
- sharl@macMini docker %
docker run teruroomuser/hello:v1
Hello, World
イメージの配布
- sharl@macMini docker %
docker login -u teruroom11
- Password:
password
Login Succeeded
- sharl@macMini docker %
docker tag hello teruroom11/hello:v1
- sharl@macMini docker %
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello latest ed0de5516d2d 7 days ago 4.04MB
teruroom11/hello v1 ed0de5516d2d 7 days ago 4.04MB
- sharl@macMini docker %
docker push teruroom11/hello:v1
実行結果
The push refers to repository [docker.io/teruroom11/hello]
bc97656f038d: Pushed
db77520ca0aa: Pushed
115566417e3e: Mounted from library/busybox
v1: digest: sha256:2219c93fd64b74ab28fe659e8e2962faa46ad24684b9ac7353bfbb8a851d5807 size: 942
- sharl@macMini docker %
docker pull teruroom11/hello:v1
実行結果
v1: Pulling from teruroom11/hello
Digest: sha256:2219c93fd64b74ab28fe659e8e2962faa46ad24684b9ac7353bfbb8a851d5807
Status: Image is up to date for teruroom11/hello:v1
docker.io/teruroom11/hello:v1
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview teruroom11/hello:v1
- sharl@macMini docker %
docker run teruroom11/hello:v1
Hello, World
イメージの実行
- sharl@macMini docker %
docker run hello
Hello, World
- sharl@macMini docker %
docker run -it --entrypoint=/bin/sh hello
- / #
ps auxww
PID USER TIME COMMAND
1 root 0:00 /bin/sh
7 root 0:00 ps auxww
- / #
ls /
bin dev etc hello.sh home lib lib64 proc root sys tmp usr var
- / #
exit