Docker basic command



sudo docker pull ubuntu:14.04

Or ..

sudo docker pull


View mirror

sudo docker images

View native container

sudo docker ps -a

Start up

sudo docker start nickname


Create and run containers

sudo docker run -ti ubuntu:14.04 /bin/bash
sudo docker run -d -p 8080:80 --name nickname -v /webapp training/webapp ubuntu:14.04

Here -d is the background operation, -p is the fixed binding port, -P the specified port fails after restart
-v is to mount the data volume and hang the local /webapp directory to the container’s training/webapp.


sudo docker create -it ubuntu:latest

The -t option lets Docker assign a pseudo-tty and bind it to the container’s standard input, while -i lets the container’s standard input remain open.

Enter container

sudo docker attach f4850aea7048
sudo docker exec -it nickname或者id /bin/sh

It is required that the container must be running.