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
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.
Related
Sorry if this is obvious, I'm new to docker.
I forgot how I installed docker-compose, so I tried:
$ which docker-compose
/snap/bin/docker-compose
I tried to uninstall it via snap:
$ sudo snap remove docker-compose
snap "docker-compose" is not installed
$ sudo rm -r docker-compose
rm: cannot remove 'docker-compose': No such file or directory
But here's the problem:
docker-compose --version
docker-compose version 1.25.5, build unknown
It seems that docker-compose is still somewhere in the system, any ideas?
In case you did install it through apt, a
sudo apt remove docker-compose
would remove docker-compose from your system
I'm following a tutorial on docker stack, swarm, compose, etc.
the teacher connects to a VM of the swarm and then deploys a docker stack from this directory docker#node1:~/srv/swarm-stack-1:
docker stack deploy -c example-voting-app-stack.yml voteapp
However, I can't get there because I don't know how to copy the yaml compose file from the course repository to the directory inside the VM.
How can I find out where is docker#node1 located in my PC ?
Here is what I tryed:
docker-machine start node1
Docker-machine ssh node1
So I get
Tommaso#N552VW-Tommaso MINGW64 /c/Applicazioni_Tommaso/Docker Toolbox
$ Docker-machine ssh node1
( '>')
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-_--_-\) www.tinycorelinux.net
then
docker#node1:~/srv/swarm-stack-1$ pwd
/home/docker
ok then, but where is /home/docker located in my PC ?
So I tryed to get around the obstacle by creating a yml file inside the VM and then editing it, rather than copying it from another directory.
# create the directory
docker#node1:~$ mkdir srv
docker#node1:~$ cd srv
docker#node1:~/srv$ mkdir swarm-stack-1
docker#node1:~/srv$ cd swarm-stack-1
docker#node1:~/srv/swarm-stack-1$
# create the yml file
touch example-voting-app-stack.yml
and here I stop because I don't know how to edit the file.
I can nor install vim or install a program to install vim.
This is what I tryed:
docker#node1:~/srv/swarm-stack-1$ vim example-voting-app-stack.yml
-bash: vim: command not found
docker#node1:~/srv/swarm-stack-1$ apt-get vim
-bash: apt-get: command not found
docker#node1:~/srv/swarm-stack-1$ yum install vim
-bash: yum: command not found
docker#node1:~/srv/swarm-stack-1$ apk install vim
-bash: apk: command not found
docker#node1:~/srv/swarm-stack-1$ sudo apt-get install vim
sudo: apt-get: command not found
docker#node1:~/srv/swarm-stack-1$ nano
-bash: nano: command not found
So, can somebody help me to understand how to copy files inside my VM (so finding out what is its path in my PC) or how to install a program to install vim and then install vim inside my VM ?
SOLVED
The solution here is not to ssh into the VM, and instead to change to the VM context with:
docker-machine env node1
eval $(docker-machine env node1)
By doing so, you are in the VM context, so docker node ls and all the swarm commands work, but you still have access to your local files, because you're not in the VM.
So, after running the two lines above, I can finally switch my current directory to the course repo containing the docker-compose file I want to input in the docker stack deploy command, and run:
docker stack deploy -c example-voting-app-stack.yml voteapp
When you are done, to change the context back to the local machine do:
docker-machine env -u
eval $(docker-machine env -u)
I installed docker and docker-compose on my ec2 instance. I have also started docker but when I try docker-compose I get an error:
[ec2-user#ip-172-31-16-150 ~]$ sudo service docker start
[ec2-user#ip-172-31-16-150 ~]$ docker --version
Docker version 1.9.1, build a34a1d5/1.9.1
[ec2-user#ip-172-31-16-150 ~]$ docker-compose --version
docker-compose version: 1.4.2
[ec2-user#ip-172-31-16-150 ~]$ docker-compose -p docker -f my-compose.yml up -d
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
[ec2-user#ip-172-31-16-150 ~]$ sudo docker-compose -p docker -f my-compose.yml up -d
sudo: docker-compose: command not found
[ec2-user#ip-172-31-16-150 ~]$ echo $DOCKER_HOST
I've tried the command with sudo as well but it doesn't recognize docker-compose as a command
I have not set any DOCKER_HOST environment variable. I am not sure if I need to..
You'll need to run the actually command with sudo:
sudo docker-compose -p docker -f my-compose.yml up -d
Docker runs as root on your Linux system, so all the interactions with the running daemon need to be as root. You can run the commands as a user, but you're not interacting with the running system!
You can install docker-compose on Amazon Linux with:
curl -L https://github.com/docker/compose/releases/download/1.4.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose
I have successfully installed docker-machine on my Windows computer, and I'm able to use the Docker CLI on my windows box to run docker commands on a boot2docker VM.
I have docker-machine version 0.2.0, and docker 1.6.2, and the VM yields "4.0.3-boot2docker" when I run "uname -r" on it.
Now I want to install docker-compose to manage that boot2docker VM. Does docker-compose run on my Windows machine and manage the VM "remotely", as docker does, or do I have to install it on the VM itself?
On a related note, I tried installing docker-compose on my VM by doing the following:
C:\ docker-machine ssh dev
$ whoami
docker
$ sudo -i
# curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
# exit
$ which docker
/usr/local/bin/docker
$ which docker-compose
/usr/local/bin/docker-compose
This is fine, but when I try to run docker-compose it doesn't work.
$ docker-compose up
-sh: docker-compose: not found
The file is in /usr/local/bin, and it has exactly the same privileges as docker.
docker#dev:/usr/local/bin$ ls -al do*
-rwxr-xr-x 1 root root 15443675 May 13 21:24 docker
-rwxr-xr-x 1 root root 5263681 May 19 00:09 docker-compose
docker#dev:/usr/local/bin$
Is there something I'm missing?
Have a good look at the curl output. It seems that the download url is not valid anymore. I found that
curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-Linux-x86_x64
gave
{"error":"Not Found"}
For me, the current release 1.3.2 worked well, i.e.:
curl -L https://github.com/docker/compose/releases/download/1.3.2/docker-compose-Linux-x86_x64
NOTE: When using on current CoreOS don't try to output in /usr/local/bin/docker-compose as noted here. Instead use /opt/bin/docker-compose (dir may need to be created first), i.e.
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.3.2/docker-compose-Linux-x86_x64 > /opt/bin/docker-compose
I found that the download links don't work for older versions and the "install" fails silently resulting in the problem you describe. Have a look to find a download link to a current version here:
https://github.com/docker/compose/releases
Like mkoertgen said, you can always view the output from the curl command in the terminal to see that you don't get "not found" or something similar or run cat /usr/local/bin/docker-compose to verify that it's not a textfile containing "not found".
You can install docker-compose on your Windows host too.
It will manage your docker remotely. You can think of docker-compose as a more abstract interface to docker.
After running boot2docker init, run boot2docker shellinit | Invoke-Expression. This will tell docker and docker-compose where the docker server is running.
More info on installing it on Windows can be found here: http://docs.docker.com/installation/windows/
We have a linux system that we do not have full control of. Basically we cannot modify sudoers file there (it is on a remote, read only file system).
Our "solution" for hudson user to have sudo privileges was to add this user to sudo group in /etc/group file. With this approach I can execute sudo as hudson user once I ssh to the machine. However, when I try to execute sudo from a Hudson job on this system, I get the following error:
+ id
uid=60000(hudson) gid=60000(hudson) groups=60000(hudson),31(sudo)
+ cat passfile
+ sudo -S -v
Sorry, user hudson may not run sudo on sc11136681.
+ cat passfile
+ sudo -S ls /root
hudson is not allowed to run sudo on sc11136681. This incident will be reported.
The above is trying to execute:
cat passfile | sudo -S -v
cat passfile | sudo -S ls /root
Why does it work when I ssh to the machine directly but does not when Hudson uses ssh? Is there a way to make sudo work in Hudson job without adding hudson user to the sudoers file?
Edit: here is output when executing sudo commands after I ssh to the system as hudson user:
[hudson#sc11136681 ~]$ cat passfile | sudo -S -v
[sudo] password for hudson: [hudson#sc11136681 ~]$
[hudson#sc11136681 ~]$
[hudson#sc11136681 ~]$ cat passfile | sudo -S ls /root
anaconda-ks.cfg install.log.syslog jaytest
install.log iscsi_pool_protocol_fields_file subnets
The solution to this problem that worked for us was to install local sudo on the system. Command used:
sudo yum reinstall sudo
Once installed, had to make sure the right sudo was used:
export PATH=/usr/bin:$PATH
The above can be added to slave configuration so it works for all jobs on that slave.