Dokcer使用总结(Dockerfile、Compose、Swarm)

Dokcer基础查看Linux版本uname-r查看Linux详尽信息cat/etc/*eleaseCentOSLinuxrelease7.6.1810(Core)NAME="CentOSLinux"VERSION="7(Core)"ID="centos"ID_LIKE="rhelfedora"VERSION_ID="7"PRETTY_NAME="CentOSLinux7(Core)"ANSI_C...

Dokcer使用总结(Dockerfile、Compose、Swarm)

Dokcer基础

查看Linux版本

uname -r

查看Linux详尽信息

cat /etc/*elease
CentOS Linux release 7.6.1810 (Core) NAME="CentOS Linux"VERSION="7 (Core)"ID="centos"ID_LIKE="rhel fedora"VERSION_ID="7"PRETTY_NAME="CentOS Linux 7 (Core)"ANSI_COLOR="0;31"CPE_NAME="cpe:/o:centos:centos:7"HOME_URL="https://www.centos.org/"BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"CENTOS_MANTISBT_PROJECT_VERSION="7"REDHAT_SUPPORT_PRODUCT="centos"REDHAT_SUPPORT_PRODUCT_VERSION="7"CentOS Linux release 7.6.1810 (Core) CentOS Linux release 7.6.1810 (Core) 
View Code

容器的五大隔离

  • pid:进程隔离
  • net:网络隔离 (独有的ip地址,网关,子网掩码)
  • ipc:进程间交互隔离
  • mnt:文件系统隔离
  • uts:主机和域名隔离 (hostname,domainname)container 有自己的机器名

centos上安装docker

官方地址:https://docs.docker.com/install/linux/docker-ce/centos/

  1. 卸载旧版本
    sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
  2. 安装包环境
    sudo yum install -y yum-utils \  device-mapper-persistent-data \  lvm2
  3. 设置仓储地址
    sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
  4. 安装Docker-CE
    sudo yum install docker-ce docker-ce-cli containerd.io
  5. 启动Docker,运行开机自启
    systemctl start dockersystemctl enable docker

Docker安装位置

  • 查找Docker可执行程序地址/usr/bin/docker
    find / -name docker
    /run/docker/sys/fs/cgroup/pids/docker/sys/fs/cgroup/cpuset/docker/sys/fs/cgroup/freezer/docker/sys/fs/cgroup/devices/docker/sys/fs/cgroup/blkio/docker/sys/fs/cgroup/perf_event/docker/sys/fs/cgroup/memory/docker/sys/fs/cgroup/net_cls,net_prio/docker/sys/fs/cgroup/hugetlb/docker/sys/fs/cgroup/cpu,cpuacct/docker/sys/fs/cgroup/systemd/docker/etc/docker/var/lib/docker/var/lib/docker/overlay2/ec5a827479e221461a396c7d0695226ec60b642544f2f921e2da967426b1853c/diff/docker/var/lib/docker/overlay2/cf92e8387d988e9f87dc3656bb21d3a2fefff02e3505e1d282c0d105cb703ab1/merged/docker/var/lib/docker/overlay2/df3551b1764d57ad79604ace4c1b75ab1e47cdca2fb6d526940af8b400eee4aa/diff/etc/dpkg/dpkg.cfg.d/docker/usr/bin/docker/usr/share/bash-completion/completions/docker/docker
    View Code
  • 查找Docker服务端程序/usr/bin/dockerd

    find / -name dockerd
    /etc/alternatives/dockerd/var/lib/alternatives/dockerd/usr/bin/dockerd
    View Code
  • libdata: /var/lib/docker

  • config: /etc/docker

  • 查找docker.service服务程序/usr/lib/systemd/system/docker.service
    find / -name docker.service
    [root@localhost ~]# cat /usr/lib/systemd/system/docker.service[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comBindsTo=containerd.serviceAfter=network-online.target firewalld.service containerd.serviceWants=network-online.targetRequires=docker.socket[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by dockerExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockExecReload=/bin/kill -s HUP $MAINPIDTimeoutSec=0RestartSec=2Restart=always# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.# Both the old, and new location are accepted by
    源文地址:https://www.guoxiongfei.cn/cntech/21530.html