I am having problems using SSH to connect into a Docker container (from this image) running Alpine Linux 3.10.
SSH must be used for this connection, as I am using a backup software barman which requires an SSH connection to the PostgreSQL 11 database running inside the Docker container.
First I connected into the docker container using
docker exec -it <container_name> /bin/bash
then tried to reinstall and start sshd
bash-5.0# apk add openssh --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 117 MiB in 42 packages
bash-5.0# apk add openrc --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 117 MiB in 42 packages
bash-5.0# rc-update add sshd
* rc-update: sshd already installed in runlevel `sysinit'; skipping
bash-5.0# /etc/init.d/sshd start
* WARNING: sshd is already starting
However, I am unable to connect to the local sshd server from inside the Docker container
# ssh root#127.0.0.1
ssh: connect to host 127.0.0.1 port 22: Connection refused
Similarly, connecting into the Docker container via SSH from the Ubuntu host machine fails as well.
$ ssh postgres#172.26.0.4
ssh: connect to host 172.26.0.4 port 22: Connection refused
where 172.26.0.4 is the IP address shown from running ifconfig inside the Docker container.
Any ideas how we can solve this?
I didn't download the image you're referring to, but worked w/ the default docker alpine-image. To get ssh to run inside the container a few extra steps were required - there's a good chance that you need to take the same:
ssh-keygen -A
rc-status
touch /run/openrc/softlevel
/etc/init.d/sshd start
Might be relevant to your issue if you used --net=host along with docker run command:
We were facing similar issues with running SSH server inside our Ubuntu container.
We realized that the SSH server on the container's host was running and it used the same port that container's SSH server wanted to use.
We changed the port used by the SSH server to solve this issue.
Please note, our Docker container used --net=host and hence both container and host had the same IP address. Hence, the 2 SSH servers were fighting over a single port and that didn't allow the server inside the container to start properly.
Related
I am trying to install and run splash on using Windows 10 Home. I have installed docker toolbox, as on windows 10 Home you can't install docker. Then in command prompt when I type
docker pull scrapinghub/splash
I get the error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/create?fromImage=scrapinghub%2Fsplash&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
One interesting thing I noticed was that if I run Docker Quickstart Terminal I can install splash with the command
docker pull scrapinghub/splash
and then using the command
docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
it gives me
server listening on http://0.0.0.0:8050
But then when I paste http://0.0.0.0:8050 into Chrome it gives me "This site can't be reached."
Thanks
So 1st error clearly says that your Docker container is not running, so your pull command fails
You can check by running any docker command maybe try this
docker --version
For your 2nd query, you need to use Docker IP, to access the application
You can try docker-machine ip to see, on what IP docker is running (Assuming docker-machine is installed)
Generally, on windows Docker IP is 192.168.99.100
Try these 2
192.168.99.100:8050
or
localhost:8050
New user to GitLab and trying to set my Project up for the first time.
I've setup Gitlab with docker and think (I've setup a local server for it using docker??).
I've then gone created my project and added a SSH key but when I try to use the command ssh -T git#gitlab.com it fails.
I think its because I have a different domain instance name.
My problem is: what is my domain instance name and how do I find out ?
To access gitlab I just type in localhost in the browser and besides that I think its linked to one of my emails but neither works in the command
If your connection to the web GUI is localhost so your hostname/domain is the same for ssh connection.
You should make sure to open SSH port (22) to the container when you run it.
Add to docker run command -p 2222:22 this map container port 22 SSH to host port 2222 because port 22 is taken on the host by SSH already.
Edit
Jest test it on computer
After you open port for gitlab container something like this.
docker run -dit --name gitlab -p 2222:22 -p 8080:80 gitlab/gitlab-ce
Note the -p 2222:22 that probably what you missing.
You should be able to connect using ssh with this command
ssh -T git#localhost -p 2222
Good luck.
I installed a service on a remote Linux computer using docker. I used the following commands
git clone https://github.com/OpenVidu/openvidu-tutorials.git
npm install -g http-server
http-server openvidu-tutorials/openvidu-getaroom/web
docker run -p 4443:4443 --rm -e openvidu.secret=MY_SECRET -e openvidu.publicurl=https://187.84.228.66:4443 openvidu/openvidu-server-kms
But when I try do connect at the first time, I received the follow error menssage:
"ERR_EMPTY_RESPONSE", and sometime "ERR_CONNECTION_CLOSED"
I used the following diagnostic command in Linux computer “docker ps” and received the following response:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21b0620266cd openvidu/openvidu-server-kms:latest "/usr/bin/supervisor 5 days ago >Up 5 days 8443/tcp, 8888/tcp, 0.0.0.0:4443->4443/tcp, 9091/tcp sick_ritchie
What is wrong? How can I solve this?
I'm not sure sure what causes this, but when I had the same problem (with different http server) I changed listening on particular ip address (which was 127.0.0.1 in my case) to listening on all interfaces - 0.0.0.0.
I mean http server configuration, not Docker configuration.
I started a docker image using
docker run --interactive --tty node_web_1
And the running server inside the container successfully prints
Running on http://localhost:8080
in the console. I have exposed port 8080 in the Dockerfile. So in my understanding, when I call http://localhost:8080 in the browser in windows, I should access the server in the container, right? I get no reply though....
How do I go about finding the error? I executed the command
docker-machine ls
as suggested here How to access Docker container's web server from host but apparently I have no docker-machines running? What are those machines? Do I need them? I have only docker for windows installed, no additionall packages or shells.
try to publish your port
docker run -p 8080:8080 -it node_web_1
I have an Eclipse instance running on linux Ubuntu in a docker container. This container runs on a CentOS host with no physical display and I would like to forward X11 from the docker container to my laptop (running windows) through the CentOS host.
Docker container runs with
docker run --name docker-eclipse -p 5000:5000/tcp -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix
While I can forward X11 from the host to my laptp with no problems, I'm not able to start eclipse inside the container, because it dies with "Cannot open display:".
What I'd like is
laptop --> remote host --> docker container running eclipse
What is the best way to do that?
This might work (server is assumed to be the remote host running Docker, laptop is assumed to be the local host from which you want the GUI):
Connect to the server.
Mount through sshfs the laptop's .X11 socket from the server: user#server:$sshfs laptop:/tmp/.X11-unix /tmp/.X11-unix.
Start the container with something like user#laptop:ssh -X server docker run --name docker-eclipse -p 5000:5000/tcp -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix.
I'm not sure this would work, and it does not feel the cleanest way of doing so, but what you want to perform is quite.... unusual (though it would be something really great !!).
Comment your feedback !