Coturn AWS EC2 problems running - amazon-ec2

I'm trying to setup and run coturn TURN server on my EC2 instance which is on ubuntu. I have installed coturn package and trying to run the server using command line only and here is my command -
sudo turnserver -a -syslog -o -n -u [My_Username]:[My_Password] -f -p 3478 -L [AWS_Internal_IP] -X [AWS_External_IP] -r [AWS_External_IP] -v --no-dtls --no-tls -—no-cli
I get turnserver invalid option -- '?'
and the server does not run. Please help.

You should configure coturn in config file (/etc/turnserver.conf).

The last argument in your call to coturn does not start with a double dash, but with a dash and an em-dash.

Related

docker run $(pwd) command invalid in Windows

I have to run a simple front-end app on docker with nginx.
I'm following a tutorial that says to run in order:
docker build -t mytest
docker run -v $(pwd):/mnt -p 9090:9090 -w /mnt mytest ./scripts/tests.sh
the first command is ok, the app works fine.
When I run the second one I have an error:
docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
What is $(pwd)?
I read the doc about -v option but I don't understand the meaning of this variable.
I'm using Windows OS.
The cmd.exe equivalent to $PWD (which is what the tutorial should be recommending instead of the much less efficient $(pwd)) is %cd%
Thus:
docker run -v %cd%:/mnt -p 9090:9090 -w /mnt mytest ./scripts/tests.sh

docker-compose ignores DOCKER_HOST

I am attempting to run 3 Docker images, MySQL, Redis and a project of mine on Bash for Windows (WSL).
To do that I have to connect to the Docker engine running on Windows, specifically on tcp://locahost:2375. I have appended the following line to .bashrc:
export DOCKER_HOST=tcp://127.0.0.1:2375
I can successfully run docker commands like docker ps or docker run hello-world but whenever I cd into my project directory and run
sudo docker-compose up --build to load the images and spin up the containers I get an error:
ERROR: 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.
I know that if I use the -H argument I can supply the address but I'd rather find a more permanent solution. For some reason docker-compose seems to ignore the DOCKER_HOST environmental variable and I can't figure out why..
Your problem is sudo. It's a totally different program than your shell and doesn't transfer the exported environment unless you specifically tell it to. You can either add the following line in your /etc/sudoers (or /etc/sudoers.d/docker):
Defaults env_keep += DOCKER_HOST
Or you can just pass it directly to the command line:
sudo DOCKER_HOST=$DOCKER_HOST docker-compose up --build
By set DOCKER_HOST you tell for every run of docker in command line to use http api, instead of default - socket on localhost.
By default http api is not turned on
$ sudo cat /lib/systemd/system/docker.service | grep ExecStart
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
you can add -H tcp://127.0.0.1:2375 for tern on http api on localhost
but usually you want to tern on api for remote servers by -H tcp://0.0.0.0:2375 (do it only with proper firewall)
so you need to change in /lib/systemd/system/docker.service to next line
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock

docker error on windows : the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty' [duplicate]

This question already has answers here:
Error "The input device is not a TTY"
(16 answers)
Closed 2 years ago.
After I run this
docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev
I am getting the following error
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
What should I use here? I am running Docker on Windows 8 in MINGW64.
As suggested by the error message you obtain, you should try to use winpty (which is installed by default with Git-Bash) and thus run:
winpty docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev
If this works, you may want to set a Bash alias to avoid manually prepending winpty all the time:
echo "alias docker='winpty docker'" >> ~/.bashrc
or
echo "alias docker='winpty docker'" >> ~/.bash_profile
If you are using Git Bash you can try like this
winpty docker run -it ubuntu
This problem occurs when running with -it option using bash terminal on windows. You can use Powershell to resolve this issue.
This works for me.
I am using git bash on windows
winpty docker-compose exec app ls -l
Remove -it from the command. If you want to keep it interactive then keep -i
Don't use alias docker="winpty docker". It solves your problem but break pipes.
$ winpty docker run -ti ubuntu
root#e85cff7d1670:/# exit
$ wintpy docker run ubuntu bash HELLO
HELLO
$ wintpy docker run ubuntu bash HELLO | cat
stdout is not a tty
Copy this to your .bashrc. This script uses winpty docker only if -ti is used.
function docker(){
for param; do if [[ "$param" == "-ti" ]] || [[ "$param" == "-it" ]]; then
winpty docker "$#"; return
fi; done;
command docker "$#"
}
docker run -ti ubuntu becomes winpty docker run -ti ubuntu avoids error: the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"
docker run ubuntu echo "what's up" | cat becomes command docker run echo "what'up" | cat avoids error: stdout is not a tty
The script only looks if there is a '-it' parameter without checking if it is inside a 'docker run' sentence... but it does the trick for my uses.
Did you start "Docker Quickstart Terminal"? I was trying to run
$ docker run -i -t redcricket/react-tutorial:latest /bin/bash
on windows from a Cygwin bash shell and got the same error:
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
Then I remembered that when I installed docker on my windows 10 system something called "Docker Quickstart Terminal" got installed. You need to start that first from that dumb windows 'Type here to search' thing on the task bar:
That launches this …
… you can run your docker commands there without getting that error or running winpty.
The problem is with gitbash however with the powershell it is working fine ..
Happened to me. From Git Bash, on Windows 8 running Docker Toolbox. There are two things happening. From git bash, we do not seem to have complete escalated privilege to the docker daemon (even though i'm running git bash with administrative privileges).
Thus:
Try running the command from your docker terminal. (gives you privilege).
To compensate for errors from Window's folder naming formats, don't forget to quote the path.. (to escape spaces and/or capitalization errors) say
From:
docker run -v $(pwd):/data image_ref
To:
docker run -v "$(pwd):/data" image_ref
(notice the enclosing quotes in the latter around $(pwd):/data).
Just add 'winpty' in start of your cmd ,Try below:
$ winpty docker.exe run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev
Why this happens? More details here:
http://willi.am/blog/2016/08/08/docker-for-windows-interactive-sessions-in-mintty-git-bash/
Got this error for running docker-compose exec workspace bash
So just prefix with winpty winpty docker-compose exec workspace bash
It may be that you're not running your commands within the Docker terminal. If you don't, you may not be properly connected to the Docker daemon and won't be able to interact correctly.
Make sure you're running commands in the actual Docker Terminal.
For those using WSL and running Docker for windows inside of cmder or conemu I would recommend to not to use Docker which is installed on windows in 'Program Files' but instead install Docker inside WSL on ubuntu/linux. Do remember though that you can't run Docker itself from within WSL, you must connect to Docker running on windows from the linux Docker client installed in WSL.
To install Docker on WSL
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
Your options for running actual Docker commands are to either:
Connect to Docker using the switch -H
docker -H localhost:2375 run -it -v /mnt/c/code:/var/app -w "/var/app" centos:7
Or set the environment variable docker_host
export DOCKER_HOST=tcp://localhost:2375
Either way you are now be able to interactively connect to a running Docker container
you can try with Cmder tool it will work. Its not working with Gitbash
In addition to above mentioned solutions.
In case you are getting this error for docker attach
example: docker attach alpine1
error: the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
Solution: Adding winpty before docker command i.e. winpty docker attach should work.
example: winpty docker attach alpine1
Note: I was getting this error while using base on windows and this solution worked for me.
I had the same error when trying to run the docker-compose exec command.
In the help documentation docker-compose exec --help it shows how you can disable the pseudo-tty allocation by adding -T to your command options in the following way:
docker-compose exec -T
From the help documentation:
-T Disable pseudo-tty allocation. By default docker-compose exec allocates a TTY.
If you are using gitbash the problem is when setting the terminal emulator for for using with Git bash.setting the emurator
Instead you can change the emulator to the first options or use the
winpty command before your docker run command

Boot2Docker searching for docker-bootstrap.sock which does not exist

I am currently trying to set up kubernetes on a multi-docker container on CoreOS stack for AWS. To do this I need to set up etcd for flannel and am currently using this guide but am having problems at the first stage where I am suggested to run
sudo sh -c 'docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null &'
The problem is the 1st command
docker -d -H unix:///var/run/docker-bootstrap.sock
from within boot2docker. There is no docker-bootstrap.sock file in this directory and this error is thrown:
FATA[0000] An error occurred trying to connect: Post https:///var/run/docker-bootstrap.sock/v1.18/containers/create: dial unix /var/run/docker-bootstrap.sock: no such file or directory
Clearly the unix socket did not connect to this nonexistent socket.
I will note this is a very similar problem to this ticket and other tickets regarding the FATA[0000] though none seem to have asked the question in the way I currently am.
I am not an expert in unix sockets, but I am assuming there should be a file where there is not. Where can I get this file to solve my issue, or what is the recommended steps to resolve this.
specs: running OSX Yosemite but calling all commands from boot2docker
Docker should create this file for you. Are you running this command on your OS X machine? or are you running it inside the boot2docker VM?
I think you need to:
boot2docker ssh
Then:
sudo sh -c 'docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null &'
You need to make sure that command runs on the Vagrant Linux box that boot2docker creates, not your OS X machine.
Hope that helps!

Ahow to use multiple terminals in the docker container?

I know it is weird to use multiple terminals in the docker container.
My purpose is to test some commands and build a dockerfile with these commands finally.
So I need to use multiple terminals, say, two. One is running some commands, the other is used to test that commands.
If I use a real machine, I can ssh it to use multiple terminals, but in docker, how can I do this?
Maybe the solution is to run docker with CMD /bin/bash, and in that bash, using screen?
EDIT
In my situation, one shell run a server program, the other run a client program to test the server program. Because the server program and client program are compiled together. So, the default link method in docker is not suitable.
The docker way would be to run the server in one container and the client in another. You can use links to make the server visible from the client and you can use volumes to make the files at the server available from the client. If you really want to have two terminals to the same container there is nothing stopping you from using ssh. I tested this docker server:
from: https://docs.docker.com/examples/running_ssh_service/
# sshd
#
# VERSION 0.0.1
FROM ubuntu:14.04
MAINTAINER Thatcher R. Peskens "thatcher#dotcloud.com"
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
You need to base this image on your image or the otherway around to get all the functionality together. After you have built and started your container you can get it's IP using
docker inspect <id or name of container>
from the docker host you can now ssh in with root and the password from the docker file. Now you can spawn as many ssh clients as you want. I tested with:
while true; do echo "test" >> tmpfile; sleep 1; done
from one client and
tail -f tmpfile
from another
If I understand correctly the problem, then you can use nsenter.
Assuming you have a running docker named nginx (with nginx started), run the following command from the host:
nsenter -m -u -i -n -p -t `docker inspect --format {{.State.Pid}} nginx`
This will start a program in the given name space of the PID (default $SHELL).
You can run more then one shell by issuing it more then once (from the host). Then you can run any binary that exist in the given docker or tail, rm, etc files. For example, tail the log file of nginx.
Further information can be found in the nsenter man.
If you want to just play around, you can run sshd in your image and explore it the way you are used to:
docker run -d -p 22 your_image /usr/sbin/sshd -D
When you are done with your explorations, you can proceed to create Dockerfile as usual.

Resources