如何在Windows上安装docker-compose [英] How to install docker-compose on Windows
问题描述
如果我在boot2docker中键入以下命令,如docker网站所示:
curl -L https:// github .com / docker / compose / releases / download / 1.1.0 / docker-compose-`uname -s` -`uname -m`> / usr / local / bin / docker-compose
chmod + x / usr / local / bin / docker-compose
当我输入以下命令来检查安装是否成功时,我得到:
/ usr /本地/ bin / docker-compose:行1:语法错误:意外的换行
那么,在boot2docker上安装docker-compose?
更新2017:现在正式管理(适用于支持Hyper-V的Windows 10) Docker for Windows。
请参见安装Docker for Windows 。
它有一个巧克力安装 Docker的包,所以:
choco install docker-for-windows
#或
choco upgrade docker-for-windows
再次,这需要一个64位的Windows 10 Pro,企业和教育(11月15日更新,Build 10586或更高版本)和Microsoft Hyper-V。
对于其他Windows,您仍然需要VirtualBox + Boot2Docker。
更新:码头工作组合1.5 ( 2015年11月)应该使它正式可用于Windows(自RC2)。
拉请求像 PR 2230 和 PR 2143 帮助。
提交13d5efc 详细介绍官方Build proc
原始答案(2015年第Q1季Q3)。
警告:根据 docker-compose 在容器中) //github.com/edmorleyrel =nofollow noreferrer> Ed Morley( edmorley
)。
docker-compose in a container方法似乎存在缓存问题(请参阅问题#6:对docker-compose.yml和Dockerfile的更改未被检测到)
Ed建议:
现在,在<$ c中运行Python
docker-compose
$ c> boot2docker 似乎是W最可靠的解决方案(/)>
要从PyPI安装docker-compose,请从
boot2docker
:
docker @ boot2docker:〜$
tce-load -wi python&&卷曲https://bootstrap.pypa.io/get-pip.py | \
sudo python - &&& sudo pip install -U docker-compose
要保存运行每次
boot2docker
VM重新启动(由于更改不会持续),您可以使用bootlocal.sh
所以:
docker @ boot2docker:〜$
echo'su docker -c tce-load -wi python&& \
curl https://bootstrap.pypa.io/get-pip.py | \
python - &&& pip install -U docker-compose'| \
sudo tee /var/lib/boot2docker/bootlocal.sh> / dev / null&&& \
sudo chmod + x /var/lib/boot2docker/bootlocal.sh
(
su docker -c
需要体操,因为tce-load
不能作为root
和bootlocal.sh
以root
运行。chmod
bootlocal.sh
应该不必要一次#915 被修复。
将-a
添加到tee
命令,如果你需要追加,而不是覆盖bootlocal.sh
。)
如果您希望使用docker-compose的预发行版本,请使用
pip install替换
或等同物。pip install -U docker-compose
-U docker-compose> = 1.3.0rc1
原始答案:
我还运行图片中的 docker-compose
(在Windows boot2docker上):
- 克隆 https://github.com/docker/compose 在
/ c / Users /< username> / myproject / compose
(为了具有持久性,因为/ c / Users /< username>
当我使用VirtualBox及其扩展包时自动挂载) -
建立码头组合图像:
cd / c / Users /< username> / myproject / compose
#这将把回购放在一个独立的HEAD中,但这并不重要
git checkout 1.2.0
docker build -t docker-compose。
-
添加'
dc
别名(在个人资料
文件,我复制到我的/home/docker/.ashrc
启动boot2docker ssh会话)dc ='docker run --rm -i -t -v /var/run/docker.sock:/var/run/docker.sock -v`pwd`:`pwd` -w`pwd` docker-compose'
从那里,一个' dc up
'或' dc ps
'只是工作。在Windows上使用boot2docker 1.6。
If I type the following commands in boot2docker as shown on the docker website:
curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
When I type the following commands to check if the installation was successful, I get:
/usr/local/bin/docker-compose: line 1: syntax error: unexpected newline
So, how can I install docker-compose on boot2docker ?
Update 2017: this is now officially managed (for Windows 10 supporting Hyper-V) with "Docker for Windows".
See "Install Docker for Windows".
It does have a chocolatey installation package for Docker, so:
choco install docker-for-windows
# or
choco upgrade docker-for-windows
Again, this requires a 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later) and Microsoft Hyper-V.
For other Windows, you still need VirtualBox + Boot2Docker.
Update: docker compose 1.5 (Nov 2015) should make it officially available for Windows (since RC2).
Pull requests like PR 2230 and PR 2143 helped.
Commit 13d5efc details the official Build process for the Windows binary.
Original answer (Q1-Q3 2015).
Warning: the original answer ("docker-compose
in a container") below seems to have a bug, according to Ed Morley (edmorley
).
There appear to be caching issues with the "docker-compose in a container" method (See issue #6: "Changes to docker-compose.yml and Dockerfile not being detected")
As such for now, running the Python
docker-compose
package insideboot2docker
seems to be the most reliable solution for Windows users (having spent many hours trying to battle with the alternatives).To install docker-compose from PyPI, run this from inside
boot2docker
:
docker@boot2docker:~$
tce-load -wi python && curl https://bootstrap.pypa.io/get-pip.py | \
sudo python - && sudo pip install -U docker-compose
To save having to run the above every time the
boot2docker
VM is restarted (since changes don't persist), you can usebootlocal.sh
like so:
docker@boot2docker:~$
echo 'su docker -c "tce-load -wi python" && \
curl https://bootstrap.pypa.io/get-pip.py | \
python - && pip install -U docker-compose' | \
sudo tee /var/lib/boot2docker/bootlocal.sh > /dev/null && \
sudo chmod +x /var/lib/boot2docker/bootlocal.sh
(The
su docker -c
gymnastics are required sincetce-load
cannot be run asroot
, andbootlocal.sh
is run asroot
. Thechmod
ofbootlocal.sh
should be unnecessary once #915 is fixed.
Add-a
to thetee
command if you need to append, rather than overwritebootlocal.sh
.)If you wish to use a pre-release version of docker-compose, then replace
pip install -U docker-compose
withpip install -U docker-compose>=1.3.0rc1
or equivalent.
Original answer:
I also run docker-compose
(on Windows boot2docker) in a image by:
- cloning https://github.com/docker/compose in
/c/Users/<username>/myproject/compose
(in order to have persistence, since/c/Users/<username>
is automatically mounted, when I use VirtualBox with its extension pack ) building the docker-compose image:
cd /c/Users/<username>/myproject/compose # that will put the repo in a detached HEAD, but it does not matter here git checkout 1.2.0 docker build -t docker-compose .
adding a '
dc
' alias (in aprofile
file that I copy to my/home/docker/.ashrc
before launching the boot2docker ssh session.)dc='docker run --rm -i -t -v /var/run/docker.sock:/var/run/docker.sock -v `pwd`:`pwd` -w `pwd` docker-compose'
From there, a 'dc up
' or 'dc ps
' just works. On Windows. With boot2docker 1.6.
这篇关于如何在Windows上安装docker-compose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!