Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 588
Magick Avatar asked Aug 04 '16 19:08

Magick


People also ask

What is the command for Docker compose?

Description. You can use compose subcommand, docker compose [-f <arg>...] [options] [COMMAND] [ARGS...] , to build and manage multiple services in Docker containers.


Video Answer


2 Answers

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

like image 106
pelican Avatar answered Sep 28 '22 21:09

pelican


The output of dpkg -s ... demonstrates that docker-compose is not installed from a package. Without more information from you there are at least two possibilities:

  1. docker-compose simply isn't installed at all, and you need to install it.

    The solution here is simple: install docker-compose.

  2. docker-compose is installed in your $HOME directory (or other location not on root's $PATH).

    There are several solution in this case. The easiest is probably to replace:

    sudo docker-compose ... 

    With:

    sudo `which docker-compose` ... 

    This will call sudo with the full path to docker-compose.

    You could alternatively install docker-compose into a system-wide directory, such as /usr/local/bin.

like image 26
larsks Avatar answered Sep 28 '22 20:09

larsks