Install Docker Machine

本文介绍如何在macOS、Linux及Windows系统上安装Docker Machine,包括直接安装二进制文件的方法,并提供了验证安装及安装bash补全脚本的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自官网文档:https://docs.docker.com/machine/install-machine/


On macOS and Windows, Machine is installed along with other Docker products when you install the Docker for MacDocker for Windows, or Docker Toolbox.

If you want only Docker Machine, you can install the Machine binaries directly by following the instructions in the next section. You can find the latest versions of the binaries are on the docker/machine release page on GitHub.

Installing Machine Directly

  1. Install the Docker binary.

  2. Download the Docker Machine binary and extract it to your PATH.

    If you are running on macOS:

    $ curl -L https://github.com/docker/machine/releases/download/v0.9.0-rc2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
    chmod +x /usr/local/bin/docker-machine
    

    If you are running on Linux:

    $ curl -L https://github.com/docker/machine/releases/download/v0.9.0-rc2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
      chmod +x /tmp/docker-machine &&
      sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
    

    If you are running with Windows with git bash:

    $ if [[ ! -d "$HOME/bin" ]]; then mkdir -p "$HOME/bin"; fi && \
      curl -L https://github.com/docker/machine/releases/download/v0.9.0-rc2/docker-machine-Windows-x86_64.exe > "$HOME/bin/docker-machine.exe" && \
      chmod +x "$HOME/bin/docker-machine.exe"
    

    Otherwise, download one of the releases from the docker/machine release page directly.

  3. Check the installation by displaying the Machine version:

    $ docker-machine version
    docker-machine version 0.8.2, build e18a919
    

Installing bash completion scripts

The Machine repository supplies several bash scripts that add features such as:

  • command completion
  • a function that displays the active machine in your shell prompt
  • a function wrapper that adds a docker-machine use subcommand to switch the active machine

To install the scripts, copy or link them into your /etc/bash_completion.d or /usr/local/etc/bash_completion.d directory. To enable the docker-machine shell prompt, add $(__docker_machine_ps1) to your PS1 setting in ~/.bashrc.

PS1='[\u@\h \W$(__docker_machine_ps1)]\$ '

You can find additional documentation in the comments at the top of each script.

How to uninstall

To uninstall Docker Machine:

  • Remove the executable: rm $(which docker-machine)

  • Optionally, remove the machines you created.

    To remove each machine individually: docker-machine rm <machine-name>

    To remove all machines: docker-machine rm -f $(docker-machine ls -q)

Removing machines is an optional step because there are cases where you might want to save and migrate existing machines to a Docker for Mac or Docker for Windows environment, for example.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值