Windows Docker Desktop容器自动化管理
我们使用Docker compose和开源工具Dobi(GitHub - dnephin/dobi: A build automation tool for Docker applications)从一个Linux基础容器镜像(我们使用Almalinux),构建支持SSH两个容器,以及一个具备X11 forwarding的有Google chrome浏览器和Jetbain idea集成开发工具的容器。借鉴如此容器环境构建,可以很方便来搭建基于Windows下容器环境的Hadoop、Spark大数据教学开发的环境。可以参考本作者的另外几篇文章:Windows PC上创建大数据职业技能竞赛实验环境之一 / 七。
首先我们来看看什么是Docker compose。Docker compose 是用于定义和运行多容器 Docker 应用程序的工具。通过 Compose,您可以使用 YML 文件来配置应用程序需要的所有服务。然后,使用一个命令,就可以从 YML 文件配置中创建并启动所有服务。Windows下安装Docker Desktop,应该也有了Docker compose。
C:\MyDevz\dockerp>docker version
Client:Cloud integration: v1.0.29Version: 20.10.21API version: 1.41Go version: go1.18.7Git commit: baeda1fBuilt: Tue Oct 25 18:08:16 2022OS/Arch: windows/amd64Context: defaultExperimental: trueServer: Docker Desktop 4.14.1 (91661)Engine:Version: 20.10.21API version: 1.41 (minimum version 1.12)Go version: go1.18.7Git commit: 3056208Built: Tue Oct 25 18:00:19 2022OS/Arch: linux/amd64Experimental: falsecontainerd:Version: 1.6.9GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536frunc:Version: 1.1.4GitCommit: v1.1.4-0-g5fd4c4ddocker-init:Version: 0.19.0GitCommit: de40ad0C:\MyDevz\dockerp>docker-compose version
Docker Compose version v2.13.0
开源工具Dobi是一款Docker应用的自动化构建工具,用Dobi能保持项目高效组织,方便重构。他采用dobi.yaml来具体定义容器构建的资源与任务,并直接用dobi运行任务。Dobi可以通过github下载,具有windows和linux的不同程序。这里是windows下载链接:https://github.com/dnephin/dobi/releases/download/v0.15.0/dobi-windows.exe
一 构建支持SSH的容器镜像
创建项目目录,我的是C:\mydevz\dockerp。进入项目于目录。将下载好的dobi拷贝到目录,修改文件名。
dobi-windows.exe -> dobi.exe
1 在当前目录下创建Dockerfile。
FROM almalinux:latest
MAINTAINER "LIU Gang from Hiroki Takeyama"# sshd
RUN dnf -y install openssh-server openssh-clients; \sed -i 's/^\(UsePAM yes\)/# \1/' /etc/ssh/sshd_config; \ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' && \ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''; \sed -i 's/^#\(PermitRootLogin\) .*/\1 yes/' /etc/ssh/sshd_config; \rm -f /run/nologin; \dnf clean all;# 免密
RUN sed -i 's/^#\(PubkeyAuthentication yes\)/\1/' /etc/ssh/sshd_config && \echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config; \ssh-keygen -t rsa -f /root/.ssh/id_rsa -P '' && \cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;# 基础应用
RUN dnf -y install net-tools iproute procps;
RUN dnf -y install bzip2 wget vim less;
RUN dnf clean all;# 环境变量
ENV TIMEZONE Asia/Shanghai
ENV ROOT_PASSWORD ******* # root登录密码RUN ln -fs /usr/share/zoneinfo/${TIMEZONE} /etc/localtime; \echo "root:${ROOT_PASSWORD}" | chpasswd; \touch /var/log/lastlog;# 暴露ssh端口
EXPOSE 22ENTRYPOINT ["/usr/sbin/init"]
在Dockerfile中通过ENTRYPOINT ["/usr/sbin/init"],让容器启动时启动systemd。
2 创建dobi.yaml。
meta:project: dockerpdefault: createimage=almalinux:image: almalinuxcontext: .dockerfile: Dockerfiletags: - 'S0.1'
# - '{env.VERSION}'annotations:description: "Build the almalinux image"alias=create:tasks: ['almalinux:build']annotations:description: "Create the images and containers"alias=clean:tasks: ['almalinux:rm']annotations:description: "Remove the images and containers"
这时我们可以来创建新的容器镜像almalinux:S0.1。
C:\MyDevz\dockerp>dobi --version
dobi version 0.15.0 (build: 5c1481d, date: Sat Feb 27 19:05:16 UTC 2021)C:\MyDevz\dockerp>dobi list
Resources:almalinux Build the almalinux imageclean Remove the images and containerscreate Create the images and containersC:\MyDevz\dockerp>dobi
[WARN] Failed to load auth config: no docker configuration found
Step 1/12 : FROM almalinux:latest---> 39f63d416992
Step 2/12 : MAINTAINER "LIU Gang from Hiroki Takeyama"---> Running in ecec068122c7
Removing intermediate container ecec068122c7---> b84502db34ad
Step 3/12 : RUN dnf -y install openssh-server openssh-clients; sed -i 's/^\(UsePAM yes\)/# \1/' /etc/ssh/sshd_config; ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' && ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''; sed -i 's/^#\(PermitRootLogin\) .*/\1 yes/' /etc/ssh/sshd_config; rm -f /run/nologin; dnf clean all;---> Running in 21c50551fb82
AlmaLinux 8 - BaseOS 1.3 MB/s | 2.9 MB 00:02
AlmaLinux 8 - AppStream 3.2 MB/s | 9.9 MB 00:03
AlmaLinux 8 - Extras 7.5 kB/s | 18 kB 00:02
Dependencies resolved.
================================================================================Package Arch Version Repository Size
================================================================================
Installing:openssh-clients x86_64 8.0p1-16.el8 baseos 668 kopenssh-server x86_64 8.0p1-16.el8 baseos 492 k
Installing dependencies:libedit x86_64 3.1-23.20170329cvs.el8 baseos 102 kopenssh x86_64 8.0p1-16.el8 baseos 522 kTransaction Summary
================================================================================
Install 4 PackagesTotal download size: 1.7 M
Installed size: 5.5 M
Downloading Packages:
(1/4): libedit-3.1-23.20170329cvs.el8.x86_64.rp 213 kB/s | 102 kB 00:00
(2/4): openssh-8.0p1-16.el8.x86_64.rpm 792 kB/s | 522 kB 00:00
(3/4): openssh-clients-8.0p1-16.el8.x86_64.rpm 947 kB/s | 668 kB 00:00
(4/4): openssh-server-8.0p1-16.el8.x86_64.rpm 1.7 MB/s | 492 kB 00:00
--------------------------------------------------------------------------------
Total 947 kB/s | 1.7 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1Running scriptlet: openssh-8.0p1-16.el8.x86_64 1/4Installing : openssh-8.0p1-16.el8.x86_64 1/4Installing : libedit-3.1-23.20170329cvs.el8.x86_64 2/4Installing : openssh-clients-8.0p1-16.el8.x86_64 3/4Running scriptlet: openssh-server-8.0p1-16.el8.x86_64 4/4Installing : openssh-server-8.0p1-16.el8.x86_64 4/4Running scriptlet: openssh-server-8.0p1-16.el8.x86_64 4/4Verifying : libedit-3.1-23.20170329cvs.el8.x86_64 1/4Verifying : openssh-8.0p1-16.el8.x86_64 2/4Verifying : openssh-clients-8.0p1-16.el8.x86_64 3/4Verifying : openssh-server-8.0p1-16.el8.x86_64 4/4Installed:libedit-3.1-23.20170329cvs.el8.x86_64 openssh-8.0p1-16.el8.x86_64openssh-clients-8.0p1-16.el8.x86_64 openssh-server-8.0p1-16.el8.x86_64Complete!
Generating public/private dsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_ed25519_key.
Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:M6RQtXJ0ZIUQFTmr4L6VESV/a5o6M+WykpkiJ+cIMoc root@21c50551fb82
The key's randomart image is:
+---[DSA 1024]----+
| ..*=B=. |
| . . B+ |
| . . = .o. |
| ..= ... . |
| ...S. o |
| . . .=.+ |
|E . . +ooo |
|.+o.+ *.=.. |
| .*...oo* |
+----[SHA256]-----+
28 files removed
Removing intermediate container 21c50551fb82---> 587e9b935679
Step 4/12 : RUN sed -i 's/^#\(PubkeyAuthentication yes\)/\1/' /etc/ssh/sshd_config && echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config; ssh-keygen -t rsa -f /root/.ssh/id_rsa -P '' && cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys;---> Running in aa037c31e575
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:z6FY6ztEAvyZWRHe+iLF6pNy3CVFsancUCS81wLcYlA root@aa037c31e575
The key's randomart image is:
+---[RSA 3072]----+
| . .=E=+. |
| o .B+oo |
| o *o=+. |
| *oo=+ . |
| oSoo. |
| =o*.. |
| .+++o+ |
| ..=oo. |
| o..oo |
+----[SHA256]-----+
Removing intermediate container aa037c31e575---> 36c28e11a985
Step 5/12 : RUN dnf -y install net-tools iproute procps;---> Running in a27cd3468aa5
AlmaLinux 8 - BaseOS 590 kB/s | 2.9 MB 00:04
AlmaLinux 8 - AppStream 3.1 MB/s | 9.9 MB 00:03
AlmaLinux 8 - Extras 11 kB/s | 18 kB 00:01
Dependencies resolved.
================================================================================Package Architecture Version Repository Size
================================================================================
Installing:iproute x86_64 5.18.0-1.el8 baseos 807 knet-tools x86_64 2.0-0.52.20160912git.el8 baseos 321 kprocps-ng x86_64 3.3.15-9.el8 baseos 328 k
Installing dependencies:libbpf x86_64 0.5.0-1.el8 baseos 136 klibmnl x86_64 1.0.4-6.el8 baseos 30 kpsmisc x86_64 23.1-5.el8 baseos 150 kTransaction Summary
================================================================================
Install 6 PackagesTotal download size: 1.7 M
Installed size: 5.0 M
Downloading Packages:
(1/6): libmnl-1.0.4-6.el8.x86_64.rpm 88 kB/s | 30 kB 00:00
(2/6): libbpf-0.5.0-1.el8.x86_64.rpm 281 kB/s | 136 kB 00:00
(3/6): net-tools-2.0-0.52.20160912git.el8.x86_6 937 kB/s | 321 kB 00:00
(4/6): iproute-5.18.0-1.el8.x86_64.rpm 1.1 MB/s | 807 kB 00:00
(5/6): procps-ng-3.3.15-9.el8.x86_64.rpm 1.5 MB/s | 328 kB 00:00
(6/6): psmisc-23.1-5.el8.x86_64.rpm 926 kB/s | 150 kB 00:00
--------------------------------------------------------------------------------
Total 510 kB/s | 1.7 MB 00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1Installing : psmisc-23.1-5.el8.x86_64 1/6Installing : libmnl-1.0.4-6.el8.x86_64 2/6Running scriptlet: libmnl-1.0.4-6.el8.x86_64 2/6Installing : libbpf-0.5.0-1.el8.x86_64 3/6Installing : iproute-5.18.0-1.el8.x86_64 4/6Installing : procps-ng-3.3.15-9.el8.x86_64 5/6Installing : net-tools-2.0-0.52.20160912git.el8.x86_64 6/6Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 6/6Verifying : iproute-5.18.0-1.el8.x86_64 1/6Verifying : libbpf-0.5.0-1.el8.x86_64 2/6Verifying : libmnl-1.0.4-6.el8.x86_64 3/6Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 4/6Verifying : procps-ng-3.3.15-9.el8.x86_64 5/6Verifying : psmisc-23.1-5.el8.x86_64 6/6Installed:iproute-5.18.0-1.el8.x86_64 libbpf-0.5.0-1.el8.x86_64libmnl-1.0.4-6.el8.x86_64 net-tools-2.0-0.52.20160912git.el8.x86_64procps-ng-3.3.15-9.el8.x86_64 psmisc-23.1-5.el8.x86_64Complete!
Removing intermediate container a27cd3468aa5---> 77d12e5c28f6
Step 6/12 : RUN dnf -y install bzip2 wget vim less;---> Running in 2a473b8ea2ac
Last metadata expiration check: 0:00:07 ago on Fri Dec 2 07:35:10 2022.
Package less-530-1.el8.x86_64 is already installed.
Dependencies resolved.
================================================================================Package Arch Version Repository Size
================================================================================
Installing:bzip2 x86_64 1.0.6-26.el8 baseos 60 kvim-enhanced x86_64 2:8.0.1763-19.el8_6.4 appstream 1.4 Mwget x86_64 1.19.5-10.el8 appstream 733 k
Installing dependencies:gpm-libs x86_64 1.20.7-17.el8 appstream 38 klibmetalink x86_64 0.1.3-7.el8 baseos 32 klibpsl x86_64 0.20.2-6.el8 baseos 61 kpublicsuffix-list-dafsa noarch 20180723-1.el8 baseos 56 kvim-common x86_64 2:8.0.1763-19.el8_6.4 appstream 6.3 Mvim-filesystem noarch 2:8.0.1763-19.el8_6.4 appstream 49 kwhich x86_64 2.21-18.el8 baseos 48 kTransaction Summary
================================================================================
Install 10 PackagesTotal download size: 8.8 M
Installed size: 33 M
Downloading Packages:
(1/10): libmetalink-0.1.3-7.el8.x86_64.rpm 86 kB/s | 32 kB 00:00
(2/10): libpsl-0.20.2-6.el8.x86_64.rpm 148 kB/s | 61 kB 00:00
(3/10): bzip2-1.0.6-26.el8.x86_64.rpm 142 kB/s | 60 kB 00:00
(4/10): which-2.21-18.el8.x86_64.rpm 388 kB/s | 48 kB 00:00
(5/10): publicsuffix-list-dafsa-20180723-1.el8. 315 kB/s | 56 kB 00:00
(6/10): gpm-libs-1.20.7-17.el8.x86_64.rpm 298 kB/s | 38 kB 00:00
(7/10): vim-filesystem-8.0.1763-19.el8_6.4.noar 308 kB/s | 49 kB 00:00
(8/10): wget-1.19.5-10.el8.x86_64.rpm 1.8 MB/s | 733 kB 00:00
(9/10): vim-enhanced-8.0.1763-19.el8_6.4.x86_64 2.1 MB/s | 1.4 MB 00:00
(10/10): vim-common-8.0.1763-19.el8_6.4.x86_64. 4.9 MB/s | 6.3 MB 00:01
--------------------------------------------------------------------------------
Total 2.0 MB/s | 8.8 MB 00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1Installing : vim-filesystem-2:8.0.1763-19.el8_6.4.noarch 1/10Installing : vim-common-2:8.0.1763-19.el8_6.4.x86_64 2/10Installing : gpm-libs-1.20.7-17.el8.x86_64 3/10Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64 3/10Installing : which-2.21-18.el8.x86_64 4/10Installing : publicsuffix-list-dafsa-20180723-1.el8.noarch 5/10Installing : libpsl-0.20.2-6.el8.x86_64 6/10Installing : libmetalink-0.1.3-7.el8.x86_64 7/10Installing : wget-1.19.5-10.el8.x86_64 8/10Running scriptlet: wget-1.19.5-10.el8.x86_64 8/10Installing : vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 9/10Installing : bzip2-1.0.6-26.el8.x86_64 10/10Running scriptlet: bzip2-1.0.6-26.el8.x86_64 10/10Running scriptlet: vim-common-2:8.0.1763-19.el8_6.4.x86_64 10/10Verifying : bzip2-1.0.6-26.el8.x86_64 1/10Verifying : libmetalink-0.1.3-7.el8.x86_64 2/10Verifying : libpsl-0.20.2-6.el8.x86_64 3/10Verifying : publicsuffix-list-dafsa-20180723-1.el8.noarch 4/10Verifying : which-2.21-18.el8.x86_64 5/10Verifying : gpm-libs-1.20.7-17.el8.x86_64 6/10Verifying : vim-common-2:8.0.1763-19.el8_6.4.x86_64 7/10Verifying : vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 8/10Verifying : vim-filesystem-2:8.0.1763-19.el8_6.4.noarch 9/10Verifying : wget-1.19.5-10.el8.x86_64 10/10Installed:bzip2-1.0.6-26.el8.x86_64gpm-libs-1.20.7-17.el8.x86_64libmetalink-0.1.3-7.el8.x86_64libpsl-0.20.2-6.el8.x86_64publicsuffix-list-dafsa-20180723-1.el8.noarchvim-common-2:8.0.1763-19.el8_6.4.x86_64vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64vim-filesystem-2:8.0.1763-19.el8_6.4.noarchwget-1.19.5-10.el8.x86_64which-2.21-18.el8.x86_64Complete!
Removing intermediate container 2a473b8ea2ac---> a6a8b4c3d7b3
Step 7/12 : RUN dnf clean all;---> Running in a015ca5f3ef1
28 files removed
Removing intermediate container a015ca5f3ef1---> efa368ed57d9
Step 8/12 : ENV TIMEZONE Asia/Shanghai---> Running in a032f353b151
Removing intermediate container a032f353b151---> bbadda4a968b
Step 9/12 : ENV ROOT_PASSWORD 1234509876---> Running in 02461ca03242
Removing intermediate container 02461ca03242---> c022971e8c5c
Step 10/12 : RUN ln -fs /usr/share/zoneinfo/${TIMEZONE} /etc/localtime; echo "root:${ROOT_PASSWORD}" | chpasswd; touch /var/log/lastlog;---> Running in a87f93c9a541
Removing intermediate container a87f93c9a541---> eb9dbb2e914d
Step 11/12 : EXPOSE 22---> Running in 1911fa190244
Removing intermediate container 1911fa190244---> 0f514ea28051
Step 12/12 : ENTRYPOINT ["/usr/sbin/init"]---> Running in 2fabea46bc80
Removing intermediate container 2fabea46bc80---> 2a489e613a1c
Successfully built 2a489e613a1c
Successfully tagged almalinux:S0.1
[image:build almalinux] almalinux Created
查看构建的镜像。
C:\MyDevz\dockerp>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
almalinux S0.1 2a489e613a1c 2 hours ago 309MB
3 创建docker-compose.yaml。
version: '3'services:almalinux1:image: "almalinux:S0.1"container_name: almalinux1hostname: almalinux1ports:- "2221:22"#restart: unless-stoppednetworks:network:ipv4_address: 172.99.99.11extra_hosts:- "almalinux2:172.99.99.12"privileged: truealmalinux2:image: "almalinux:S0.1"container_name: almalinux2hostname: almalinux2ports:- "2222:22"#restart: unless-stoppednetworks:network:ipv4_address: 172.99.99.12extra_hosts:- "almalinux1:172.99.99.11"privileged: truenetworks:network:driver: bridgeipam:config:- subnet: 172.99.99.0/24gateway: 172.99.99.1
4 修改dobi.yaml,dobi的任务是用docker-compose.yaml启动镜像,产生两个容器,即这里的compose=almalinux-double,他依赖镜像almalinux。
meta:project: dockerpdefault: createimage=almalinux:image: almalinuxcontext: .dockerfile: Dockerfiletags: - 'S0.1'
# - '{env.VERSION}'annotations:description: "Build the almalinux image"compose=almalinux-double:files:- docker-compose.ymlproject: 'almalinuxs'depends: [almalinux, almalinux_chrome-idea]annotations:description: "Build the almalinux double"alias=create:tasks: ['almalinux:build', 'almalinux-double:detach']annotations:description: "Create the images and containers"alias=clean:tasks: ['almalinux-double:down', 'almalinux:rm']annotations:description: "Remove the images and containers"
重新运行dobi。
C:\MyDevz\dockerp>dobi
...
...
...
[compose:detach almalinux-double] docker-compose.yml project up
failed to get console mode for stdin: The handle is invalid.
[+] Running 4/4- Network almalinuxs_network Created 0.0s- Container almalinux2 Started 0.8s- Container almalinux1 Started 1.1s
[compose:detach almalinux-double] docker-compose.yml Done
[alias:run create] Done
查看镜像和容器。
C:\MyDevz\dockerp>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
almalinux S0.1 2a489e613a1c 2 hours ago 309MBC:\MyDevz\dockerp>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f38e4b8f92b0 almalinux:S0.1 "/usr/sbin/init" 2 hours ago Up 2 hours 0.0.0.0:2222->22/tcp almalinux2
19fda9f16141 almalinux:S0.1 "/usr/sbin/init" 2 hours ago Up 2 hours 0.0.0.0:2221->22/tcp almalinux1
ssh进入容器。
二 构建运行Google chrome和Jetbrain idea镜像
在前述SSH镜像的基础上,让我们进一步构建构建运行Google chrome和Jetbrain idea镜像。
1 创建Dockerfile_chrome-idea
FROM almalinux:S0.1
MAINTAINER "LIU Gang"# X11 forward
RUN dnf -y install xorg-x11-xauth && \sed -i 's/^#\(AllowTcpForwarding yes\)/\1/' /etc/ssh/sshd_config# chrome
RUN dnf -y install mesa-dri-drivers mesa-libGL mesa-libEGL wqy-microhei-fonts
ADD google-chrome.repo /etc/yum.repos.d/
ADD linux_signing_key.pub /tmp/
RUN rpm --import linux_signing_key.pub
ADD google-chrome-stable_current_x86_64.rpm /tmp/
RUN dnf -y localinstall /tmp/google-chrome-stable_current_x86_64.rpm && \echo "export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --fork --print-address 1)" >> /root/.bashrc && \echo "alias google-chrome='google-chrome --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --ignore-certificate-errors'" >> /root/.bashrc && \rm -f /tmp/google-chrome-stable_current_x86_64.rpm && \rm -f /tmp/linux_signing_key.pub# idea
ADD ideaIC-2022.3.tar.gz /tmp/
WORKDIR /tmp
RUN mv idea-IC-223.7571.182 /usr/local && \ln -sf /usr/local/idea-IC-223.7571.182/bin/idea.sh /usr/local/bin/idea.sh && \rm -rf /tmp/idea-IC-223.7571.182RUN dnf clean all#EXPOSE 22ENTRYPOINT ["/usr/sbin/init"]
#CMD ["/usr/sbin/sshd", "-D", "-e"]
其中,添加google-chrome.repo文件。
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=0
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
预先下载 linux_signing_key.pub(https://dl.google.com/linux/linux_signing_key.pub)和google-chrome-stable_current_x86_64.rpm(https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm)以及ideaIC-2022.3.tar.gz(https://download.jetbrains.com/idea/ideaIC-2022.3.tar.gz)。
2 修改docker-compose.yaml,增加运行almalinux_chrome-idea:S0.2
version: '3'services:almalinux1:image: "almalinux:S0.1"container_name: almalinux1hostname: almalinux1ports:- "2221:22"#restart: unless-stoppednetworks:network:ipv4_address: 172.99.99.11extra_hosts:- "almalinux2:172.99.99.12"privileged: truealmalinux2:image: "almalinux:S0.1"container_name: almalinux2hostname: almalinux2ports:- "2222:22"#restart: unless-stoppednetworks:network:ipv4_address: 172.99.99.12extra_hosts:- "almalinux1:172.99.99.11"privileged: truealmalinux_chrome-idea:image: "almalinux_chrome-idea:S0.2"container_name: almalinux_chrome-ideahostname: almalinux-devports:- "2223:22"#restart: unless-stoppednetworks:network:ipv4_address: 172.99.99.19extra_hosts:- "almalinux1:172.99.99.11"- "almalinux2:172.99.99.12"privileged: truenetworks:network:driver: bridgeipam:config:- subnet: 172.99.99.0/24gateway: 172.99.99.1
3 修改dobi.yaml。新镜像almalinux_chrome-idea:S0.2要依赖镜像almalinux:S0.1,并调用docker-compose.yaml启动镜像,产生运行的容器。
meta:project: dockerpdefault: createimage=almalinux:image: almalinuxcontext: .dockerfile: Dockerfiletags: - 'S0.1'
# - '{env.VERSION}'annotations:description: "Build the almalinux image"image=almalinux_chrome-idea:image: almalinux_chrome-ideacontext: .dockerfile: Dockerfile_chrome-ideadepends: [almalinux]tags: - 'S0.2'
# - '{env.VERSION}'annotations:description: "Build almalinux chrome & idea image"compose=almalinux-double:files:- docker-compose.ymlproject: 'almalinuxs'depends: [almalinux, almalinux_chrome-idea]annotations:description: "Build the almalinux double"alias=create:tasks: ['almalinux:build', 'almalinux_chrome-idea:build', 'almalinux-double:detach']annotations:description: "Create the images and containers"alias=clean:tasks: ['almalinux-double:down', 'almalinux_chrome-idea:rm', 'almalinux:rm']annotations:description: "Remove the images and containers"
查看结果。
C:\MyDevz\dockerp>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
almalinux_chrome-idea S0.2 2e24aaaaacfb 2 hours ago 6.94GB
almalinux S0.1 2a489e613a1c 2 hours ago 309MBC:\MyDevz\dockerp>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f38e4b8f92b0 almalinux:S0.1 "/usr/sbin/init" 2 hours ago Up 2 hours 0.0.0.0:2222->22/tcp almalinux2
19fda9f16141 almalinux:S0.1 "/usr/sbin/init" 2 hours ago Up 2 hours 0.0.0.0:2221->22/tcp almalinux1
a8f60a1d85b4 almalinux_chrome-idea:S0.2 "/usr/sbin/init" 2 hours ago Up 2 hours 0.0.0.0:2223->22/tcp almalinux_chrome-idea
开启ssh终端。
Windows Docker Desktop容器自动化管理相关推荐
- windows docker desktop安装mysql[有效]
windows docker desktop安装mysql 1.拉去mysql镜像 docker pull mysql:5.7 2.查看并启动镜像 #列出已下载的镜像 docker images #启 ...
- windows docker desktop 设置2375端口远程访问
大家玩过Docker Desktop的都知道.它设置里有个2375端口是可以开放的.但是它默认绑定的是localhost. 那么有什么办法可以让别的客户端机器也能进行访问呢?这时候我们就需要用一个wi ...
- Windows下虚拟机的自动化管理
Windows下虚拟机的创建主要为VirtualBox和VMWare.本文采用VirtualBox搭建虚拟机,并使用Vagrant对虚拟机进行自动化管理,包括虚拟机的创建,虚拟机初始环境的自动化建设, ...
- Windows Docker Desktop 无法启动报错 Docker Desktop is shutting down 的可能解决办法
之前有一次 docker 启动到一半的时候电脑蓝屏了,电脑重启之后 docker 就无法启动了,一直报错 Docker Desktop is shutting down. 网上查了一下,发现一个可能的 ...
- windows Docker Desktop 怎么改变最大内存
1.使用WSL2 可以看到开启WSL2后无法在ADVANCED中设置memory大小 按下Windows + R 键,输入 %UserProfile% 并运行进入用户文件夹 新建文件 .wslconf ...
- 【docker】docker Portainer容器可视化管理工具使用文档
1.概述 转载:https://www.cnblogs.com/hellxz/p/install_portainer.html https://www.cnblogs.com/JulianHuang/ ...
- 成功解决Docker Desktop requires Windows 10 Pro or Enterprise version 15063 to run.
成功解决Docker Desktop requires Windows 10 Pro or Enterprise version 15063 to run. 目录 解决问题 解决方法 解决问题 Doc ...
- Docker Desktop 解决运行elasticsearch时出现的max virtual memory areas vm.max_map_count [65530] is too low异常
问题描述 Docker Desktop 容器运行elasticsearch提示: max virtual memory areas vm.max_map_count [65530] is too lo ...
- 从Windows走入Docker(四)如何使用Docker Desktop的快速5步教程
学习自www.docker.com 步骤1:使用本地Web服务器 在不设置IIS的情况下运行IIS 如果您以前没有运行过Docker,这里有一个快速的方法来了解Docker在工作中的力量.首先,确保您 ...
最新文章
- 实施Service Mesh前,你需要考虑这几个问题
- Python pandas
- 每天天一个linux命令echo,每天一个linux命令-echo(示例代码)
- python os 文件锁_python 中给文件加锁——fcntl模块
- linux c程序中获取shell脚本输出
- HDOJ杭电2044
- ACM 会场安排问题
- php语录网站,杨泽业:给你的wordpress博客添加经典语录功能,适合所有php网站
- 跑深度学习在Linux服务器上常用操作(ssh, screen, tensorboard, jupyter-notebook)
- 本田da屏怎么进wince系统_本田新XR-V首试:配置提升,依然好开
- java中el是什么_java中jsp的EL的定义以及使用
- 2018-2019-2 网络对抗技术 20165334 Exp7 网络欺诈防范
- sklearn 特征选择与特征抽取 —— feature_selection、feature_extraction
- 活在迷茫中,不是活在当下
- mysql的update和case when同步使用
- day6Linux命令-设置别名
- 大学计算机基础vfp程序设计课程试验报告簿,vfp实验报告2014.doc
- 怎么减小照片大小kb?
- 实现基于SSM开发房屋租赁系统
- 【油猴插件】用Tampermonkey来实现百度云满速下载和批量离线