1

When I run as docker compose as ec2-user

[ec2-user@ip-15-0-52-106 $ docker-compose --version

docker-compose version 1.11.2, build dfed245

but as root user

[root@ip-15-0-52-106 ~]# docker-compose --version

-bash: docker-compose: command not found

I get command not found.

Any idea how to run it as a root user

1
  • 1
    What is the intention/advantage of running it as a root user? Commented Mar 21, 2017 at 7:36

1 Answer 1

1

Default location of docker-compose is /usr/local/bin/docker-compose but root does not contain path /usr/local/bin.

You can check is by following command:

[root@ip-172-31-40-117 ~]# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin

[ec2-user@ip-172-31-40-117 ~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:
/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin

You can add path for root, but it may not be a good way.(https://unix.stackexchange.com/questions/115129/why-does-root-not-have-usr-local-in-path)

[ec2-user@ip-172-31-40-117 ~]$ sudo su
[root@ip-172-31-40-117 ec2-user]# cd
[root@ip-172-31-40-117 ~]# vi .bash_profile

edit like this 
export PATH=/usr/local/bin:$PATH

[root@ip-172-31-40-117 ~]# source .bash_profile

Or you can install docker-compose other path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.