Home > other >  How to make the docker to run/bin/bash the daemon way
How to make the docker to run/bin/bash the daemon way

Time:10-03

Consult everybody's got a question about docker ha, I think the docker run, run/bin/bash with 3-d parameters, and then let the bash has been running, I want to use docker attach, but I run a docker run - d.../bin/bash, the container is to stop the end of the run, what reason is this? To solve?

CodePudding user response:

Docker run specified command if it is not those who have been pending orders (for example, run top, echo), is will automatically exit, -d command is to set up the detach is true, according to the official documents, it means this command runs in the background, but it was not always run (we are in a normal run/bin/bash in the Linux Terminal, run out are finished, hanging wouldn't have been waiting for a response, so can't really use the daemon to run/bin/bash),

The local official in the early and now some of the document is inconsistent, is now a detach, said early documents specified - d in the daemon way to run a container, there may be some misunderstanding,

In addition, if you need to run the bash in the container, run directly docker run - I - t CONTAINER_NAME/bin/bash is ok, if you feel parameters than the docker attach much, can set up an alias (alias) to solve:

Alias dockerbash='docker run - I - t CONTAINER_ID/bin/bash'
Set up an alias, run directly dockerbash to get into the container to bash

CodePudding user response:

Launched a container, we may need to use SSH login in for some operation, to achieve this purpose, there are 2 points need to make sure that:

Containers must be in the running state,
Openssh server in the start state,
Note: the following example is done in the middle of ubuntu/13.10
To ensure the image with the openssh server service

# the official image generally no SSH server installation, so need to install a
Apt to get the install openssh server
-# set an initial password
Passwd 123
.
Then, submit mirror:

Docker commit CONTAINER_ID NAME/VERSION
Finally, run the mirror, and let the container always run in the background:

Let the container # first - d run in the background
# - D said at the end of the SSH daemon mode, otherwise the container starts immediately into a stopped state
Docker run - d NAME/VERSION/etc/init. D/SSH start - d
Now, can SSH login container,

Container # query IP
Docker inspect CONTAINER_ID | grep IP

# login
SSH root @ IP
# enter the password 123 landing completed
# in order to ensure the safety, please immediately use the passwd change passwords

CodePudding user response:

This demand still had better use SSL image
Run directly docker run - p tutum lying/ubuntu can
See: https://github.com/tutumcloud/tutum-ubuntu
  • Related