docker环境安装与开启远程访问
一,安装docker
1,服务器安装 docker
yum install docker
直接yum安装版本太低

2,卸载:老版本的Docker在yum中名称为docker或docker-engine,通过下面命令卸载docker和相关依赖
yum remove docker \
docker-common \
docker-selinux \
docker-engine
3,新的Docker CE在yum中被称为docker-ce。(因为分化为docker-ce和docker-ee,后者为企业版)设置yum docker repository 指定版本安装
(1),搭建Docker CE的REPOSITORY
# Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
# Use the following command to set up the stable repository. You always need the stablerepository, even if you want to install builds from the edge or test repositories as well.
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
(2),下面这个例子是使用sort -r 命令来排序docker-ce的版本,从高到低。
yum list docker-ce --showduplicates | sort -r

(3) 安装命令
# Install the latest version of Docker CE, or go to the next step to install a specific version.
yum install docker-ce
或
yum install docker-ce-18.06..ce
3,使用Docker 中国加速器
vim /etc/docker/daemon.json
添加下面代码
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"live-restore": true
}
(这个文件 初始状态是空的 只有“{}”)
启动服务
systemctl start docker
systemctl restart docker
systemctl stop docker
查看版本
docker version
查看状态
service docker status
二,开启docker远程访问
vim /etc/sysconfig/docker
在下面代码中添加红色部分
# /etc/sysconfig/docker # Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi DOCKER_OPTS="-H unix:///var/run/docker.sock -H 0.0.0.0:2376" # Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf() man page. # Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp # Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false # docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
修改服务配置:
vim /lib/systemd/system/docker.service
在下面代码中添加红色部分
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer [Service]
Type=notify
NotifyAccess=main
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
--init-path=/usr/libexec/docker/docker-init-current \
--seccomp-profile=/etc/docker/seccomp.json \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY \
$REGISTRIES \
$DOCKER_OPTS
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process [Install]
WantedBy=multi-user.target
重启docker网络
systemctl daemon-reload
重启docker服务
systemctl restart docker
在浏览器输入:http://xxx.xxx.xxx:2376/info 或http://xxx.xxx.xxx:2376/version 显示版本信息表示开启成功
配置pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>cn.meylink.test</groupId>
<artifactId>docker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>docker</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <docker.image.prefix>springboot</docker.image.prefix> </properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Docker maven plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<baseImage>java</baseImage>
<dockerHost>http://39.105.164.124:2376</dockerHost>
<!--<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>-->
<!-- copy the service's jar file from target into the root directory of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin> <!-- Docker maven plugin -->
</plugins>
</build> </project>
查看远程服务器镜像
docker images
docker环境安装与开启远程访问的更多相关文章
- docker环境安装
centos7安装docker环境 # step 1: 安装必要的一些系统工具 yum install -y yum-utils device-mapper-persistent-data lvm2 ...
- 【linux】【redis】redis安装及开启远程访问
系统环境:Centos7 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API. 1.yum安装过程参考:https ...
- docker 环境安装 jenkins
下载镜像运行 jenkins 默认服务器已经安装好了 docker 环境: 拉取 jenkins 镜像 docker pull jenkins/jenkins:lts 镜像的详细信息可以查看:http ...
- win7下docker环境安装
最近公司涉及到对docker容器引擎的使用,所以就在网上各种搜索,由于是win7系统,所以在使用上更是麻烦,遇到各种错误就是无法成功启动docker,经过两天的各种尝试下,终于安装成功,在此记录一下使 ...
- Autoware docker 环境安装
环境: ubuntu 16.04 GPU:GeForce 1070 nvidia 驱动型号:nvidia_driver_390.67 安装参考网址: https://github.com/C ...
- docker 环境安装
centos7下安装docker.docker-compose 参考文档:https://docs.docker.com/ 一.安装docker 1).Docker 要求 CentOS 系统的内核版本 ...
- 搭建docker环境,安装常用应用(单机)
## 安装docker ```bash1.卸载系统之前dockersudo yum remove docker \ docker-client \ docker-client-latest \ doc ...
- Windows docker环境安装
前期准备 1.hyper-v功能 win10家庭版没有提供hyper-v的问题可通过如下脚本解决,保存为bat并运行重启电脑即可. pushd "%~dp0" dir /b %Sy ...
- Docker环境安装与配置
Docker 简介 Docker使用Go语言编写的 安装Docker推荐LInux内核在3.10上 在2.6内核下运行较卡(CentOS 7.X以上内核是3.10) Docker 安装 安装yum-u ...
随机推荐
- 【Coucurrency-CountDownLatch】-20161203-0002
简介 java异步任务相关的工具.主要用在某些线程需要等到其他线程完成某些操作后才能执行的场景. 等待线程需要显示的调用wait方法,表示线程当前挂起,需要等到countdownLatch到0才执行. ...
- redis的LRU算法(二)
前文再续,书接上一回.上次讲到redis的LRU算法,文章实在精妙,最近可能有机会用到其中的技巧,顺便将下半部翻译出来,实现的时候参考下. 搏击俱乐部的第一法则:用裸眼观测你的算法 Redis2.8的 ...
- pdf.js 使用实例(app直接预览pdf格式的文档)
pdf.js可以实现在html下直接浏览pdf文档,是一款开源的pdf文档读取解析插件 pdf.js主要包含两个库文件,一个pdf.js和一个pdf.worker.js,,一个负责API解析,一个负责 ...
- linux配置服务器
梳理一下这次配置服务器的思路. 1,挂载磁盘 Java和neigx上传到根目录下,tomcat放在data目录下,数据库新建文件夹也在data下, 2,配置环境变量 3,nginx修改域名 4,数据库 ...
- java的AES对称加密和解密,有偏移量
import java.math.BigDecimal; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; i ...
- 走过的easyui的坑--datagrid的reload在IE下未刷新
至于为什么要进easyui这个坑,就不多说了. 我现在使用的是1.5这个版本,在用它做一个后台管理系统,项目做到一半,才想起记录这些坑. 1.对于datagrid在reload.load在IE下未刷新 ...
- js中substr、substring、slice的区别
substr(start, length) substring(from, to) slice(from, to) 以上函数只传一个参数时,认为是起始位置,然后按照正方向截取 substring的参数 ...
- 解题报告 『宝藏(Prim思想 + 访问顺序随机)』
原题地址 本以为不过是一道Prim算法模版题,但貌似只能得45分,虽然对我这种蒟蒻来说已经够了. 然而同机房大佬表示可以用模拟退火A了此题,遂习之,终无所获. 然而机缘巧合之下习得了另一种随机算法,于 ...
- 《python for data analysis》第二章,美国1880-2010年出生人口姓名的数据分析
<利用python进行数据分析>第二章的姓名例子,代码.整个例子的所有代码集成到了一个文件中,导致有些对象名如year同时作为了列名与行名,会打印warning,可分不同的part依次运行 ...
- webpack学习笔记(五)
1. 如果想编写一个libray的库,代码结构如下: -library -src -index.js -math.js -string.js math.js export function add(a ...