I created the container with the following command:
docker run -d -p 52022:22 basickarl/docker-git-test
Here are the commands:
root@basickarl:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@basickarl:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4ac54468455 basickarl/docker-git-test:latest "/bin/bash" 7 minutes ago Exited (0) 26 seconds ago adoring_lumiere
22d7c5d83871 basickarl/docker-git-test:latest "/bin/bash" 2 hours ago Exited (127) About an hour ago thirsty_wright
root@basickarl:~# docker attach --sig-proxy=false e4
FATA[0000] You cannot attach to a stopped container, start it first
root@basickarl:~# docker start e4
e4
root@basickarl:~# docker attach --sig-proxy=false e4
FATA[0000] You cannot attach to a stopped container, start it first
root@basickarl:~#
Not much to say really, I'm expecting the container to start and stay upp. Here are logs:
root@basickarl:~# docker logs e4
root@basickarl:~#
You are trying to run
bash
, an interactive shell that requires a tty in order to operate. It doesn't really make sense to run this in "detached" mode with-d
, but you can do this by adding-it
to the command line, which ensures that the container has a valid tty associated with it and thatstdin
remains connected:You would more commonly run some sort of long-lived non-interactive process (like
sshd
, or a web server, or a database server, or a process manager likesystemd
orsupervisor
) when starting detached containers.If you are trying to run a service like
sshd
, you cannot simply runservice ssh start
. This will -- depending on the distribution you're running inside your container -- do one of two things:It will try to contact a process manager like
systemd
orupstart
to start the service. Because there is no service manager running, this will fail.It will actually start
sshd
, but it will be started in the background. This means that (a) theservice sshd start
command exits, which means that (b) Docker considers your container to have failed, so it cleans everything up.If you want to run just ssh in a container, consider an example like this.
If you want to run
sshd
and other processes inside the container, you will need to investigate some sort of process supervisor.What I need is to use Docker with MariaDb on different port /3301/ on my Ubuntu machine because I already had MySql installed and running on 3306.
To do this after half day searching did it using:
This pulls the image with latest MariaDb, creates container called mariaDb, and run mysql on port 3301. All data of which is located in home directory in /mdbdata/mariaDb.
To login in mysql after that can use:
Used sources are:
The answer of Iarks in this article /using -it -d was the key :) /
how-to-install-and-use-docker-on-ubuntu-16-04
installing-and-using-mariadb-via-docker
mariadb-and-docker-use-cases-part-1
Good luck all!