Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
644 views
in Technique[技术] by (71.8m points)

linux - sudo: docker-compose: command not found

I am trying to run docker-compose using sudo.

I have both docker and docker-compose installed on Ubuntu 16.01.

Due to an error while trying to download compose using curl, I ended up installing it using pip.

Docker version 1.12.0, build 8eab29e docker-compose version 1.8.0, build 94f7016

Yet, when I try to run docker-compose with sudo I get the following (using sudo with docker is fine)

sudo: docker-compose: command not found

I suppose there are differing definitions of what 'installed' means. I have been using docker-compose on the same computer that claims it is not installed.

$ dpkg -s docker-compose
dpkg-query: package 'docker-compose' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.


$ whereis docker-compose
docker-compose: /home/user/.local/bin/docker-compose

$ pip show --files docker-compose
---
Metadata-Version: 2.0
Name: docker-compose
Version: 1.8.0
Summary: Multi-container orchestration for Docker
Home-page: https://www.docker.com/
Author: Docker, Inc.
Author-email: UNKNOWN
Installer: pip
License: Apache License 2.0
Location: /home/anton/.local/lib/python2.7/site-packages
Requires: six, jsonschema, enum34, cached-property, websocket-client, docker-py, requests, docopt, dockerpty, PyYAML, texttable
Classifiers:
  Development Status :: 5 - Production/Stable
  Environment :: Console
  Intended Audience :: Developers
  License :: OSI Approved :: Apache Software License
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
Files:
  ../../../bin/docker-compose
  compose/GITSHA
  compose/__init__.py
  compose/__init__.pyc
  compose/__main__.py
  compose/__main__.pyc
  compose/bundle.py
  compose/bundle.pyc
  compose/cli/__init__.py
  compose/cli/__init__.pyc
  compose/cli/colors.py
  compose/cli/colors.pyc
  compose/cli/command.py
  compose/cli/command.pyc
  compose/cli/docker_client.py
  compose/cli/docker_client.pyc
  compose/cli/docopt_command.py
  compose/cli/docopt_command.pyc
  compose/cli/errors.py
  compose/cli/errors.pyc
  compose/cli/formatter.py
  compose/cli/formatter.pyc
  compose/cli/log_printer.py
  compose/cli/log_printer.pyc
  compose/cli/main.py
  compose/cli/main.pyc
  compose/cli/signals.py
  compose/cli/signals.pyc
  compose/cli/utils.py
  compose/cli/utils.pyc
  compose/cli/verbose_proxy.py
  compose/cli/verbose_proxy.pyc
  compose/config/__init__.py
  compose/config/__init__.pyc
  compose/config/config.py
  compose/config/config.pyc
  compose/config/config_schema_v1.json
  compose/config/config_schema_v2.0.json
  compose/config/environment.py
  compose/config/environment.pyc
  compose/config/errors.py
  compose/config/errors.pyc
  compose/config/interpolation.py
  compose/config/interpolation.pyc
  compose/config/serialize.py
  compose/config/serialize.pyc
  compose/config/sort_services.py
  compose/config/sort_services.pyc
  compose/config/types.py
  compose/config/types.pyc
  compose/config/validation.py
  compose/config/validation.pyc
  compose/const.py
  compose/const.pyc
  compose/container.py
  compose/container.pyc
  compose/errors.py
  compose/errors.pyc
  compose/network.py
  compose/network.pyc
  compose/parallel.py
  compose/parallel.pyc
  compose/progress_stream.py
  compose/progress_stream.pyc
  compose/project.py
  compose/project.pyc
  compose/service.py
  compose/service.pyc
  compose/state.py
  compose/state.pyc
  compose/utils.py
  compose/utils.pyc
  compose/volume.py
  compose/volume.pyc
  docker_compose-1.8.0.dist-info/DESCRIPTION.rst
  docker_compose-1.8.0.dist-info/INSTALLER
  docker_compose-1.8.0.dist-info/METADATA
  docker_compose-1.8.0.dist-info/RECORD
  docker_compose-1.8.0.dist-info/WHEEL
  docker_compose-1.8.0.dist-info/entry_points.txt
  docker_compose-1.8.0.dist-info/metadata.json
  docker_compose-1.8.0.dist-info/pbr.json
  docker_compose-1.8.0.dist-info/top_level.txt
Entry-points:
  [console_scripts]
  docker-compose=compose.cli.main:main

I have tried the following - but still get the same error:

$ chmod +x /home/username/.local/bin/docker-compose
$ chmod +x /home/username/.local/lib/python2.7/site-packages
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

On Ubuntu 16.04

Here's how I fixed this issue: Refer Docker Compose documentation

  1. sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

  2. sudo chmod +x /usr/local/bin/docker-compose

After you do the curl command , it'll put docker-compose into the

/usr/local/bin

which is not on the PATH. To fix it, create a symbolic link:

  1. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

And now if you do: docker-compose --version

You'll see that docker-compose is now on the PATH


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...