Обновить docker compose linux

Install Docker Compose

Estimated reading time: 8 minutes

Accelerating new features in Docker Desktop

Docker Desktop helps you build, share, and run containers easily on Mac and Windows as you do on Linux. Docker handles the complex setup and allows you to focus on writing the code. Thanks to the positive support we received on the subscription updates, we’ve started working on Docker Desktop for Linux which is the second-most popular feature request in our public roadmap. If you are interested in early access, sign up for our Developer Preview program.

This page contains information on how to install Docker Compose. You can run Compose on macOS, Windows, and 64-bit Linux.

Prerequisites

Docker Compose relies on Docker Engine for any meaningful work, so make sure you have Docker Engine installed either locally or remote, depending on your setup.

On desktop systems like Docker Desktop for Mac and Windows, Docker Compose is included as part of those desktop installs.

On Linux systems, first install the Docker Engine for your OS as described on the Get Docker page, then come back here for instructions on installing Compose on Linux systems.

To run Compose as a non-root user, see Manage Docker as a non-root user.

Install Compose

Follow the instructions below to install Compose on Mac, Windows, Windows Server 2016, or Linux systems, or find out about alternatives like using the pip Python package manager or installing Compose as a container.

The instructions below outline installation of the current stable release (v1.29.2) of Compose. To install a different version of Compose, replace the given release number with the one that you want. For instructions to install Compose 2.0.0 on Linux, see Install Compose 2.0.0 on Linux.

Compose releases are also listed and available for direct download on the Compose repository release page on GitHub. To install a pre-release of Compose, refer to the install pre-release builds section.

Install Compose on macOS

Docker Desktop for Mac includes Compose along with other Docker apps, so Mac users do not need to install Compose separately. For installation instructions, see Install Docker Desktop on Mac.

Install Compose on Windows desktop systems

Docker Desktop for Windows includes Compose along with other Docker apps, so most Windows users do not need to install Compose separately. For install instructions, see Install Docker Desktop on Windows.

If you are running the Docker daemon and client directly on Microsoft Windows Server, follow the instructions in the Windows Server tab.

Install Compose on Windows Server

Follow these instructions if you are running the Docker daemon and client directly on Microsoft Windows Server and want to install Docker Compose.

Start an “elevated” PowerShell (run it as administrator). Search for PowerShell, right-click, and choose Run as administrator. When asked if you want to allow this app to make changes to your device, click Yes.

In PowerShell, since GitHub now requires TLS1.2, run the following:

Then run the following command to download the current stable release of Compose (v1.29.2):

Note: On Windows Server 2019, you can add the Compose executable to $Env:ProgramFiles\Docker . Because this directory is registered in the system PATH , you can run the docker-compose —version command on the subsequent step with no additional configuration.

Test the installation.

Install Compose on Linux systems

On Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub. Follow the instructions from the link, which involve running the curl command in your terminal to download the binaries. These step-by-step instructions are also included below.

For alpine , the following dependency packages are needed: py-pip , python3-dev , libffi-dev , openssl-dev , gcc , libc-dev , rust , cargo and make .

Run this command to download the current stable release of Docker Compose:

To install a different version of Compose, substitute 1.29.2 with the version of Compose you want to use.

If you have problems installing with curl , see Alternative Install Options tab above.

Читайте также:  Какое последнее обновление windows 10 pro

Apply executable permissions to the binary:

Note: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path.

Optionally, install command completion for the bash and zsh shell.

Test the installation.

Alternative install options

Install using pip

For alpine , the following dependency packages are needed: py-pip , python3-dev , libffi-dev , openssl-dev , gcc , libc-dev , rust , cargo , and make .

Compose can be installed from pypi using pip . If you install using pip , we recommend that you use a virtualenv because many operating systems have python system packages that conflict with docker-compose dependencies. See the virtualenv tutorial to get started.

If you are not using virtualenv,

pip version 6.0 or greater is required.

Install as a container

Compose can also be run inside a container, from a small bash script wrapper. To install compose as a container run this command:

Install pre-release builds

If you’re interested in trying out a pre-release build, you can download release candidates from the Compose repository release page on GitHub. Follow the instructions from the link, which involves running the curl command in your terminal to download the binaries.

Pre-releases built from the “master” branch are also available for download at https://dl.bintray.com/docker-compose/master/.

Pre-release builds allow you to try out new features before they are released, but may be less stable.

Upgrading

If you’re upgrading from Compose 1.2 or earlier, remove or migrate your existing containers after upgrading Compose. This is because, as of version 1.3, Compose uses Docker labels to keep track of containers, and your containers need to be recreated to add the labels.

If Compose detects containers that were created without labels, it refuses to run, so that you don’t end up with two sets of them. If you want to keep using your existing containers (for example, because they have data volumes you want to preserve), you can use Compose 1.5.x to migrate them with the following command:

Alternatively, if you’re not worried about keeping them, you can remove them. Compose just creates new ones.

Uninstallation

To uninstall Docker Compose if you installed using curl :

To uninstall Docker Compose if you installed using pip :

Got a “Permission denied” error?

If you get a “Permission denied” error using either of the above methods, you probably do not have the proper permissions to remove docker-compose . To force the removal, prepend sudo to either of the above commands and run again.

Источник

Compose file versions and upgrading

Estimated reading time: 15 minutes

The Compose file is a YAML file defining services, networks, and volumes for a Docker application.

The Compose file formats are now described in these references, specific to each version.

Reference file What changed in this version
Compose Specification (most current, and recommended) Versioning
Version 3 Version 3 updates
Version 2 Version 2 updates
Version 1 (Deprecated) Version 1 updates

The topics below explain the differences among the versions, Docker Engine compatibility, and how to upgrade.

Compatibility matrix

There are several versions of the Compose file format – 1, 2, 2.x, and 3.x

This table shows which Compose file versions support specific Docker releases.

Compose file format Docker Engine release
Compose specification 19.03.0+
3.8 19.03.0+
3.7 18.06.0+
3.6 18.02.0+
3.5 17.12.0+
3.4 17.09.0+
3.3 17.06.0+
3.2 17.04.0+
3.1 1.13.1+
3.0 1.13.0+
2.4 17.12.0+
2.3 17.06.0+
2.2 1.13.0+
2.1 1.12.0+
2.0 1.10.0+

In addition to Compose file format versions shown in the table, the Compose itself is on a release schedule, as shown in Compose releases, but file format versions do not necessarily increment with each release. For example, Compose file format 3.0 was first introduced in Compose release 1.10.0, and versioned gradually in subsequent releases.

The latest Compose file format is defined by the Compose Specification and is implemented by Docker Compose 1.27.0+.

Looking for more detail on Docker and Compose compatibility?

We recommend keeping up-to-date with newer releases as much as possible. However, if you are using an older version of Docker and want to determine which Compose release is compatible, refer to the Compose release notes. Each set of release notes gives details on which versions of Docker Engine are supported, along with compatible Compose file format versions. (See also, the discussion in issue #3404.)

For details on versions and how to upgrade, see Versioning and Upgrading.

Versioning

There are three legacy versions of the Compose file format:

Version 1. This is specified by omitting a version key at the root of the YAML.

Version 2.x. This is specified with a version: ‘2’ or version: ‘2.1’ , etc., entry at the root of the YAML.

Version 3.x, designed to be cross-compatible between Compose and the Docker Engine’s swarm mode. This is specified with a version: ‘3’ or version: ‘3.1’ , etc., entry at the root of the YAML.

The latest and recommended version of the Compose file format is defined by the Compose Specification. This format merges the 2.x and 3.x versions and is implemented by Compose 1.27.0+.

v2 and v3 Declaration

Note: When specifying the Compose file version to use, make sure to specify both the major and minor numbers. If no minor version is given, 0 is used by default and not the latest minor version.

The Compatibility Matrix shows Compose file versions mapped to Docker Engine releases.

To move your project to a later version, see the Upgrading section.

Note: If you’re using multiple Compose files or extending services, each file must be of the same version — you cannot, for example, mix version 1 and 2 in a single project.

Several things differ depending on which version you use:

  • The structure and permitted configuration keys
  • The minimum Docker Engine version you must be running
  • Compose’s behaviour with regards to networking

These differences are explained below.

Version 1 (Deprecated)

Compose files that do not declare a version are considered “version 1”. In those files, all the services are declared at the root of the document.

Version 1 is supported by Compose up to 1.6.x. It will be deprecated in a future Compose release.

Version 1 files cannot declare named volumes, networks or build arguments.

Compose does not take advantage of networking when you use version 1: every container is placed on the default bridge network and is reachable from every other container at its IP address. You need to use links to enable discovery between containers.

Version 2

Compose files using the version 2 syntax must indicate the version number at the root of the document. All services must be declared under the services key.

Version 2 files are supported by Compose 1.6.0+ and require a Docker Engine of version 1.10.0+.

Named volumes can be declared under the volumes key, and networks can be declared under the networks key.

By default, every container joins an application-wide default network, and is discoverable at a hostname that’s the same as the service name. This means links are largely unnecessary. For more details, see Networking in Compose.

When specifying the Compose file version to use, make sure to specify both the major and minor numbers. If no minor version is given, 0 is used by default and not the latest minor version. As a result, features added in later versions will not be supported. For example:

Источник

Compose V2

Estimated reading time: 6 minutes

Compose V2 and the new docker compose command

The new Compose V2, which supports the compose command as part of the Docker CLI, is now available.

Compose V2 integrates compose functions into the Docker platform, continuing to support most of the previous docker-compose features and flags. You can test the Compose V2 by simply replacing the dash ( — ) with a space, and by running docker compose , instead of docker-compose .

Starting with Docker Desktop 3.4.0, you can run Compose V2 commands without modifying your invocations, by enabling the drop-in replacement of the previous docker-compose with the new command. See the section Installing Compose V2 for detailed instructions how to enable the drop-in replacement.

Context of Docker Compose evolution

Introduction of the Compose specification makes a clean distinction between the Compose YAML file model and the docker-compose implementation. Making this change has enabled a number of enhancements, including adding the compose command directly into the Docker CLI, being able to “up” a Compose application on cloud platforms by simply switching the Docker context, and launching of Amazon ECS and Microsoft ACI. As the Compose specification evolves, new features land faster in the Docker CLI.

While docker-compose is still supported and maintained, Compose V2 implementation relies directly on the compose-go bindings which are maintained as part of the specification. This allows us to include community proposals, experimental implementations by the Docker CLI and/or Engine, and deliver features faster to users. Compose V2 also supports some of the newer additions to the Compose specification, such as profiles and GPU devices.

Additionally, Compose V2 also supports Apple silicon.

For more information about the flags that are supported in the new compose command, see the docker-compose compatibility list.

Transitioning to GA for Compose V2

We are currently working towards providing a standard way to install Compose V2 on Linux. When this is available, Compose V2 will be marked as Generally Available (GA).

Compose V2 GA means:

  • New features and bug fixes will only be considered in the Compose V2 code base.
  • Docker Compose V2 will be the default setting in Docker Desktop for Mac and Windows. You can still opt out through the Docker Desktop UI and the CLI. This means, when you run docker-compose , you will actually be running docker compose .
  • Compose V2 will be included with the latest version of the Docker CLI. You can use Compose Switch to redirect docker-compose to docker compose .
  • Compose V2 branch will become the default branch.
  • Docker Compose V1 will be maintained to address any security issues.

We would like to make the Compose V2 transition to be as smooth as possible for all users. We currently don’t have a concrete timeline to deprecate Compose V1. We will review the feedback from the community on the GA and the adoption on Linux, and come up with a plan to deprecate Compose V1. We are not planning to remove the aliasing of docker-compose to docker compose . We would like to make it easier for users to switch to V2 without breaking any existing scripts. We will follow up with a blog post with more information on the exact timeline on V1 deprecation and the end of support policies for security issues.

Your feedback is important to us. Reach out to us and let us know your feedback on our Public Roadmap.

Installing Compose V2

This section contains instructions on how to install Compose V2.

Install on Mac and Windows

Docker Desktop for Mac and for Windows version 3.2.1 and above includes the new Compose command along with the Docker CLI. Therefore, Windows and Mac users do not need to install Compose V2 separately.

We will progressively turn Docker Compose V2 on automatically for Docker Desktop users, so that users can seamlessly move to Docker Compose V2 without the need to change any of their scripts. If you run into any problems with Compose V2, you can simply switch back to Compose v1, either in Docker Desktop, or in the CLI.

For Docker Desktop installation instructions, see:

To disable Docker Compose V2 using Docker Desktop:

  1. From the Docker menu, click Preferences (Settings on Windows) >General.
  2. Clear the Use Docker Compose V2 check box.

To disable Docker Compose V2 using the CLI, run:

Install on Linux

You can install Compose V2 by downloading the appropriate binary for your system from the project release page and copying it into $HOME/.docker/cli-plugins as docker-compose .

Run the following command to download the current stable release of Docker Compose:

This command installs Compose V2 for the active user under $HOME directory. To install Docker Compose for all users on your system, replace

/.docker/cli-plugins with /usr/local/lib/docker/cli-plugins .

Apply executable permissions to the binary:

Test your installation

Compose Switch

Compose Switch is a replacement to the Compose V1 docker-compose (python) executable. Compose switch translates the command line into Compose V2 docker compose and then runs the latter.

To install Compose Switch automatically, run:

To install Compose Switch manually:

Download the compose-switch binary for your architecture

Run the following command to make it an executable:

Rename the docker-compose binary if you’ve already installed it as /usr/local/bin/docker-compose

Define an alternatives group for the docker-compose command:

Verify your installation:

Uninstall Docker Compose

If you installed Docker Compose using curl, run the following command to uninstall:

Источник

Читайте также:  Как поставить иконку мой компьютер windows 10
Оцените статью