概念与安装

三大核心概念:

  镜像(Image):创建Docker容器的基础
  容器(Container):运行和隔离应用
 
    Note: 镜像本身是只读的。容器从镜像启动的时候,会在镜像的最上层创建一个可写层。
  仓库(Repository):集中存放镜像文件的场所。每个仓库存放一类镜像,通过标签(tag)区分
    Note: 仓库注册服务器:存放(多个)仓库
 
版本管理,增量的文件系统
 
ubuntu 安装教程:
 

配置docker服务:

为了避免每次使用 docker 都要切换到特殊身份,可以将当前用户加入到安装中自动创建的 docker 用户组,代码如下:
sudo usermod -aG docker USER_NAME
 
使用 dockerd 命令启动,开启 debug 模式,监听本地 2376 端口
dockerd -D -H tcp://127.0.0.1:2376
这些选项可以写入 /etc/docker/ 路径下的 daemon.json 文件中
{
"debug": true,
"host": ["tcp://127.0.0.1:2376"]
}
 
ubuntu 系统中,docker 服务的默认配置文件为 /etc/default/docker:
# Docker Upstart and SysVinit configuration file
 
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/admin/systemd/
#
 
# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"
 
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
 
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
 
# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"
View Code

可以通过修改其中的 DOCKER_OPTS 来修改服务器启动的参数,例如让 docker 开启 2375 端口监听:

DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
修改之后,通过service重启docker
sudo service docker restart
 
RedHat, centOS系统中,用systemd管理,配置文件路径为/etc/systemd/system/docker.service.d/docker.conf。更新配置后,需要通过systemctl命令管理docker服务:
sudo systemctl daemon-reload
sudo systemctl start docker.service

查看服务日志:

RadHat 中日志文件可能为 /var/log/massages
Ubuntu,centOS中,使用 journalctl -u docker.service
重启后,可以查看 docker info 确保正确运行。
 
posted @ 2020-01-01 19:55  catyuang  阅读(128)  评论(0编辑  收藏  举报