安装静态二进制文件
参考地址:https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries
下载静态二进制存档。转到 https://download.docker.com/linux/static/stable/ (或更改stable
为nightly
或test
),选择您的硬件平台,然后下载.tgz
与您要安装的Docker Engine-Community版本有关的文件。
本文章下载为:docker-19.03.5.tgz 注意要跟据平台硬件下载以免造成不兼容
将下载好的文件上传到服务器
20191225111836.png
解压文件
tar xzvf docker-19.03.5.tgz
20191225112103.png
将二进制文件移到可执行路径上的目录,例如/usr/bin/
sudo cp docker/* /usr/bin/
配置 docker.service文件
vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
启动dockerd服务进程
systemctl daemon-reload
systemctl start docker.service
查看docker 安装信息
docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.6 (Maipo)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.795GiB
Name: localhost.localdomain
ID: AV7D:WG7N:CATA:5SOR:IDCS:OPLA:QXVN:5Z3E:P6BH:5YHL:3IMT:FGLP
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
开机自动启动
sudo systemctl enable docker
由于我们是在无网络状态下安装的docker 容器所以我们也需要下载相关的镜像进行试运行
使用有网服务器下载好镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.5 d404d78aa797 7 months ago 205MB
保存
docker save d404d78aa797 > mysql5.tar
查看保存的tar
[root@localhost ynxx]# ls
mysql5.tar
将此镜像上传到所需安装的服务器中
导入镜像
mysql5.tar 为需导入的镜像
[root@localhost ynxx]# docker load < mysql5.tar
6270adb5794c: Loading layer [==================================================>] 58.45MB/58.45MB
432b5f62e513: Loading layer [==================================================>] 338.4kB/338.4kB
647245c554e4: Loading layer [==================================================>] 10.44MB/10.44MB
ddc265b679cf: Loading layer [==================================================>] 4.472MB/4.472MB
af84b063c827: Loading layer [==================================================>] 1.536kB/1.536kB
f83622e85376: Loading layer [==================================================>] 41.54MB/41.54MB
4054cc666efd: Loading layer [==================================================>] 94.41MB/94.41MB
90b4ae8695b5: Loading layer [==================================================>] 3.584kB/3.584kB
a9c5a24e943f: Loading layer [==================================================>] 3.584kB/3.584kB
f49eaacc87a0: Loading layer [==================================================>] 9.728kB/9.728kB
c9f3545812c8: Loading layer [==================================================>] 1.536kB/1.536kB
Loaded image ID: sha256:d404d78aa797c87c255e5ae2beb5d8d0e4d095f930b1f20dc208eaa957477b74
查看导入的镜像
[root@localhost ynxx]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> d404d78aa797 7 months ago 205MB
重命名镜像
[root@localhost ynxx]# docker tag d404d78aa797 mysql:5.5
[root@localhost ynxx]# docker images #再次查看名称已更改
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.5 d404d78aa797 7 months ago 205MB
启动镜像
[root@localhost ynxx]# docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.5
8cd5768993ea2f21362504a034aff0e1543c99acc917a2da113600096619b934
[root@localhost ynxx]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8cd5768993ea mysql:5.5 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:3306->3306/tcp mysql-test
进入容器中登录
[root@localhost ynxx]# docker exec -it 8cd5768993ea /bin/bash
root@8cd5768993ea:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
到此结束,在无网络的情况下,安装docker---->上传打包的镜像---> 运行镜像
注意:docker save与docker export的区别
参考地址:
https://blog.csdn.net/sun_qiangwei/article/details/80766800
网友评论