Start the daemon container

Docker run -d Specifies the container nameCopy the code
  • Using mirrored centos: Latest Start a container in background mode
docker run -d centos
Copy the code

  • Problem: Then docker ps-a to check, it will find that the container has quit, it is important to note that docker container background operation, there must be a foreground process. Commands run by the container that are not always pending (such as running top, tail) will exit automatically.
  • This is a docker mechanism problem, such as your Web container, let’s take nginx as an example, under normal circumstances, we configure to start the service only need to start the response service. Such as:service nginx startHowever, by doing so, Nginx runs in background process mode, and the docker foreground has no running applications. Such a container will commit suicide immediately after the background starts because it feels like it has nothing more to do. Therefore, the best solution is to run your application as a console process
  • Note: Docker delivery always returns a dummy terminal number

Viewing container Logs

docker logs -f -t --tail 
Copy the code