directory search
Compose About versions and upgrading (Compose) ASP.NET Core + SQL Server on Linux (Compose) CLI environment variables (Compose) Command-line completion (Compose) Compose(组成) Compose command-line reference(组合命令行参考) Control startup order (Compose) Django and PostgreSQL (Compose) Docker stacks and distributed application bundles (Compose) docker-compose build(docker-compose构建) docker-compose bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .NET Core application (Engine) About images, containers, and storage drivers (Engine) Add nodes to the swarm (Engine) Apply custom metadata (Engine) Apply rolling updates (Engine) apt-cacher-ng Best practices for writing Dockerfiles (Engine) Binaries (Engine) Bind container ports to the host (Engine) Breaking changes (Engine) Build your own bridge (Engine) Configure container DNS (Engine) Configure container DNS in user-defined networks (Engine) CouchDB (Engine) Create a base image (Engine) Create a swarm (Engine) Customize the docker0 bridge (Engine) Debian (Engine) Default bridge network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (Engine) Fedora (Engine) Get started (Engine) Get started with macvlan network driver (Engine) Get started with multi-host networking (Engine) How nodes work (Engine) How services work (Engine) Image management (Engine) Inspect the service (Engine) Install Docker (Engine) IPv6 with Docker (Engine) Join nodes to a swarm (Engine) Legacy container links (Engine) Lock your swarm (Engine) Manage nodes in a swarm (Engine) Manage sensitive data with Docker secrets (Engine) Manage swarm security with PKI (Engine) Manage swarm service networks (Engine) Migrate to Engine 1.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale the service (Engine) SDKs (Engine) Select a storage driver (Engine) Set up for the tutorial (Engine) SSHd (Engine) Storage driver overview (Engine) Store service configuration data (Engine) Swarm administration guide (Engine) Swarm mode key concepts (Engine) Swarm mode overlay network security model (Engine) Swarm mode overview (Engine) Understand container communication (Engine) Use multi-stage builds (Engine) Use swarm mode routing mesh (Engine) Use the AUFS storage driver (Engine) Use the Btrfs storage driver (Engine) Use the Device mapper storage driver (Engine) Use the OverlayFS storage driver (Engine) Use the VFS storage driver (Engine) Use the ZFS storage driver (Engine) Engine: Admin Guide Amazon CloudWatch logs logging driver (Engine) Bind mounts (Engine) Collect Docker metrics with Prometheus (Engine) Configuring and running Docker (Engine) Configuring logging drivers (Engine) Control and configure Docker with systemd (Engine) ETW logging driver (Engine) Fluentd logging driver (Engine) Format command and log output (Engine) Google Cloud logging driver (Engine) Graylog Extended Format (GELF) logging driver (Engine) Journald logging driver (Engine) JSON File logging driver (Engine) Keep containers alive during daemon downtime (Engine) Limit a container's resources (Engine) Link via an ambassador container (Engine) Log tags for logging driver (Engine) Logentries logging driver (Engine) PowerShell DSC usage (Engine) Prune unused Docker objects (Engine) Run multiple services in a container (Engine) Runtime metrics (Engine) Splunk logging driver (Engine) Start containers automatically (Engine) Storage overview (Engine) Syslog logging driver (Engine) tmpfs mounts Troubleshoot volume problems (Engine) Use a logging driver plugin (Engine) Using Ansible (Engine) Using Chef (Engine) Using Puppet (Engine) View a container's logs (Engine) Volumes (Engine) Engine: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor security profiles for Docker (Engine) Automation with content trust (Engine) Content trust in Docker (Engine) Delegations for content trust (Engine) Deploying Notary (Engine) Docker security (Engine) Docker security non-events (Engine) Isolate containers with a user namespace (Engine) Manage keys for content trust (Engine) Play in a content trust sandbox (Engine) Protect the Docker daemon socket (Engine) Seccomp security profiles for Docker (Engine) Secure Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver options and operating system defaults (Machine) Drivers overview (Machine) Exoscale (Machine) Generic (Machine) Get started with a local VM (Machine) Google Compute Engine (Machine) IBM Softlayer (Machine) Install Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (Machine) Oracle VirtualBox (Machine) Provision AWS EC2 instances (Machine) Provision Digital Ocean Droplets (Machine) Provision hosts in the cloud (Machine) Rackspace (Machine) VMware Fusion (Machine) VMware vCloud Air (Machine) VMware vSphere (Machine) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
characters

要开始使用 Fedora 上的 Docker CE,请确保满足先决条件,然后安装 Docker。

先决条件

Docker EE客户

Docker EE 在 Fedora 上不受支持。有关不同 Docker 版本支持的操作系统和发行版的列表,请参阅 Docker变体。

OS要求

要安装 Docker,您需要这些 Fedora 版本的64位版本:

  • 二十四

  • 二十五

  • 二十六

注意:Fedora 26软件包目前仅在边缘测试存储库中可用。

卸载旧版本

老版本的 Docker 被称为dockerdocker-engine。如果安装了它们,请卸载它们以及相关的依赖项。

$ sudo dnf remove docker \
                  docker-common \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

如果dnf报告说没有安装这些软件包,那就行了。

/var/lib/docker/包括图像,容器,卷和网络的内容将被保留。现在调用 Docker CE 包docker-ce

安装Docker CE

您可以根据您的需要以不同的方式安装 Docker CE:

  • 大多数用户设置 Docker 的存储库并从中进行安装,以便安装和升级任务。这是推荐的方法。

  • 有些用户下载 RPM 软件包并手动安装,并完全手动管理升级。这对于在无法访问互联网的空隙系统上安装 Docker 等情况很有用。

  • 在测试和开发环境中,有些用户选择使用自动便利脚本来使用存储库安装 Docker.Install。首次在新主机上安装 Docker CE 之前,需要设置 Docker 存储库。之后,您可以从存储库安装和更新 Docker CE。设置存储库

  • dnf-plugins-core从命令行安装提供命令来管理 DNF 存储库的软件包。

$ sudo dnf -y安装dnf-plugins-core

  1. 使用以下命令设置稳定的存储库。即使您想从边缘测试存储库安装构建,也总是需要稳定的存储库。$ sudo dnf config-manager \ --add-repo \      https://download.docker.com/linux/fedora/docker-ce.repo

  1. 可选:启用边缘测试存储库。这些存储库包含在上述docker.repo文件中,但默认情况下处于禁用状态。您可以将它们与稳定的存储库一起启用。

注意:Fedora 26软件包目前仅在边缘测试存储库中可用。

$ sudo dnf config-manager --set-enabled docker-ce-edge

$ sudo dnf config-manager --set-enabled docker-ce-test

您可以通过使用该标志运行命令来禁用边缘测试存储库。要重新启用它,请使用标志。以下命令禁用边缘存储库。dnf config-manager--disable--enable

$ sudo dnf config-manager --set-disabled docker-ce-edge

注意:从Docker 17.06开始,稳定版本也被推到边缘测试版本库。

了解稳定边缘频道。

安装Docker CE

  1. 更新dnf软件包索引。$ sudo dnf makecache fast如果这是自添加Docker存储库以来首次刷新包索引,系统将提示您接受GPG密钥,并显示密钥的指纹。验证指纹是否匹配060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35,如果是,请接受密钥。

  1. 安装最新版本的 Docker CE,或转到下一步安装特定版本。

$ sudo dnf安装docker-ce

有多个Docker存储库?

如果启用了多个 Docker 存储库,则安装或更新时未指定版本dnf installdnf update命令将始终安装尽可能高的版本,这可能不适合您的稳定性需求。

  1. 在生产系统上,您应该安装特定版本的Docker CE,而不是始终使用最新版本。列出可用的版本。此示例使用该sort -r命令按版本号对结果进行排序,从最高到最低并被截断。  注意:该dnf list命令仅显示二进制包。要显示源包,请.x86_64从包名中省略。$ dnf list docker-ce.x86_64 --showduplicates | sort -r docker-ce.x86_64 17.06.0.fc24 docker-ce-stable列表的内容取决于启用了哪些存储库,并且将针对您的Fedora版本(由.fc24本例中的版本后缀)。选择一个特定的版本进行安装。第二列是版本字符串。第三列是存储库名称,它指示软件包来自哪个存储库并且通过扩展其稳定性级别。要安装特定版本,请将版本字符串附加到包名称并用连字符(-)分隔它们:$ sudo dnf -y install docker-ce- <VERSION>

  1. 启动Docker。

$ sudo systemctl启动docker

  1. 通过运行hello-world映像验证是否正确安装了Docker CE 。$ sudo docker run hello-world这个命令下载一个测试图像并在容器中运行它。当容器运行时,它会打印一条信息消息并退出.Docker CE已安装并正在运行。您需要使用sudo运行Docker命令。继续Linux postinstall以允许非特权用户运行Docker命令以及其他可选配置步骤。升级Docker CETo升级Docker CE,首先运行sudo dnf makecache fast,然后按照安装说明选择要安装的新版本。从package安装.Ifall你不能使用Docker的仓库来安装Docker,你可以下载.rpm文件供您发布并手动安装。每次要升级Docker CE时,都需要下载一个新文件。

  1. 转到https://download.docker.com/linux/fedora/并选择您的Fedora版本。转到x86_64/stable/Packages/并下载.rpm您想要安装的Docker版本的文件。

注意:要安装边缘软件包,stable请将URL中的单词更改为edge

  1. 安装Docker CE,将下面的路径更改为您下载Docker软件包的路径。$ sudo dnf -y install /path/to/package.rpm

  1. 启动Docker。

$ sudo systemctl启动docker

  1. Verify that Docker CE is installed correctly by running the hello-world image. $ sudo docker run hello-world  This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.Docker CE is installed and running. You need to use sudo to run Docker commands. Continue to Post-installation steps for Linux to allow non-privileged users to run Docker commands and for other optional configuration steps.Upgrade Docker CETo upgrade Docker CE, download the newer package file and repeat the installation procedure, using dnf -y upgrade instead of dnf -y install, and pointing to the new file.Install using the convenience scriptDocker provides convenience scripts at get.docker.com and test.docker.com用于快速和非交互式地将Docker CE的稳定版和测试版安装到开发环境中。脚本的源代码位于docker-install存储库中。不建议在生产环境中使用这些脚本,并且在使用它们之前应了解其潜在风险:

  1. 脚本需要rootsudo权限才能运行。因此,在运行脚本之前,应仔细检查和审核脚本。

  1. 这些脚本会尝试检测您的 Linux 发行版和版本,并为您配置您的软件包管理系统。另外,这些脚本不允许您自定义任何安装参数。这可能会导致不支持的配置,无论是从 Docker 的角度还是从您自己的组织准则和标准。

  1. 这些脚本会安装包管理器的所有依赖关系和建议,而不要求确认。这可能会安装大量的包,具体取决于主机的当前配置。

  1. 如果 Docker 已经使用其他机制安装在主机上,请不要使用便捷脚本。

本示例使用get.docker.com上的脚本在 Linux 上安装 Docker CE 的最新稳定版本。要安装最新的测试版本,请改用test.docker.com。在下面的每个命令,取代每次出现gettest

警告:在本地运行之前,始终检查从互联网上下载的脚本。

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh<output truncated>If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface         for more information.

Docker CE 已安装。它会自动启动DEB基于目录的分发。在RPM基于分布的情况下,您需要使用适当systemctlservice命令手动启动它。如消息所示,非root用户默认情况下无法运行 Docker 命令。

在使用便利脚本后升级 Docker

如果您使用便捷脚本安装 Docker,则应直接使用软件包管理器升级 Docker。重新运行便捷脚本没有任何优势,如果它试图重新添加已添加到主机的存储库,则会产生问题。

卸载Docker CE

  1. 卸载Docker包: $sudo df移除码头-ce

  1. 不会自动删除主机上的图像,容器,卷或自定义配置文件。删除所有图像,容器和卷:

$sudo rm-RF/var/lib/docker

您必须手动删除任何已编辑的配置文件。

下一步

  • 继续进行Linux的安装后步骤

  • 继续使用用户指南。

Previous article: Next article: