Running Ubuntu system in Docker container

original site

I am only used to using the Centos system, but it is very troublesome and inconvenient to compile and install some software, but it becomes easy and convenient in Ubuntu, so I plan to use docker to run the Ubuntu system to make up for the shortcomings and shortcomings of Centos;

Project address : https://hub.docker.com/_/ubuntu/

1. Install the Ubuntu system command:
docker pull  ubuntu
This is an extremely streamlined system, without even the most basic wget command; so first, apt-get update is required to upgrade the system and install the apt-get install wget command;

2. Run the command to enter the Ubuntu system:
docker run -ti ubuntu bash

3. The correct way to exit the system :
press first, ctrl+p
and then press, ctrl+q
must not use exit or ctrl+d to exit, so the whole system will exit! ! !

4. Share the host directory to the Ubuntu system:
docker run -it -v /AAA:/BBB ubuntu bash
so that the AAA folder in the root directory of the host is mapped to the container Ubuntu, and can be shared between the two;

5. Log in to the ubuntu mirroring system in docker :
docker run -ti ubuntu /bin/bash
#6866 is the first four digits of the IMAGE ID - you can distinguish which image it is

6. Exit and then enter ubuntu
1. First use docker ps -a to find the corresponding number of the CONTAINER ID (for example: 0a3309a3b29e)
2. Enter the system docker attach 0a3309a3b29e (there is no response at this time, ctrl+c will enter the ubuntu system went)

PS: The command I run

docker run -it -v /download:/download -p 53:53 ubuntu bash

Additional common commands:

1. Check the ubuntu version: cat /etc/issue
2. Modify the ubuntu mirror source to ubuntu:
1. Backup  cp /etc/apt/sources.list /etc/apt/sources.list.backup
2. Clear the content and add the following content  vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http:/ /mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty -updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
3、更新生效:apt-get update

3. Install and enable ssh to run user remote login

1. Install the sshd command: apt-get install openssh-server openssh-client

2. Edit /etc/ssh/sshd_config  , comment out: PermitRootLogin without-password, increase PermitRootLogin yes

3. Start the command
service ssh start
service ssh stop
service ssh restart


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324859258&siteId=291194637