Run
1. Running a docker in the background
docker run -d centos /bin/sh -c "while true;do echo is running; sleep 1;done"
# -d Run the container in the background
# /bin/sh Specifies the bash interpreter using centos
# -c Run a shell command
# "while true;do echo is running; sleep 1;done" is running in the linux background, running once per second
docker ps # check container process
docker logs -f container id/name # log information for uninterrupted print container
docker stop centos # stop container
2. Start a bash terminal and allow users to interact
docker run --name mydocker -it centos /bin/bash
# --name defines a name for the container
# -i keep the standard input of the container open
# -t Let Docker assign a pseudo terminal and bind it to the standard input of the container
# /bin/bash Specify the docker container to interact with the shell interpreter3.Restart a stopped container
4.commit custom image
5.External access container
Last updated