docker pulls images, creates and starts containers

get mirror

By default, the [docker] pull command will pull the image locally from the official Docker Hub repository.

First introduce the format of this command:

docker pull [OPTIONS] :
where,

docker pull: Command keywords for Docker to pull images;
[OPTIONS]: Command options;
Warehouse name: The format of the warehouse name is generally /. For Docker Hub, if the user name is not specified, the default is library, which is the official image;
label: label is an important parameter to distinguish different versions of the image, :

docker pull ubuntu:14.04

#Pull busybox:1.27 image 
# ********** Begin ********* #
docker pull busybox:1.27
#********** End **********#

The first way: create a new one and start it.

The docker run command will create a container based on the specified image and start it. The basic syntax of docker run is as follows:

docker run [OPTIONS] Image name [COMMAND] [ARG]
Among them,

docker run: Command keywords for Docker to create and start containers;
OPTIIONS: command options, the most commonly used include -d to run the container in the background and return the container ID, -i to run the container in interactive mode, -t to assign a pseudo input terminal to the container, –name Specifies the name of the startup container. For more options, please refer to the Docker help documentation;
Image name: specified in the form of :

The second way: start a terminated container

Use the docker start command to start a terminated container with the container name or container id.

docker start [OPTIONS] container [container2…]
where:

docker start: the command keyword for Docker to start the container;
OPTIIONS: command options;
container: the container to be started, which is represented by “container ID” or “container name”, if multiple containers are specified, then these containers will be start up.
Suppose a container named firstContainer is in the terminated state, and now it needs to be started. You can do this: execute docker start firstContainer, after the command is executed, try to start the firstContainer container, and execute the start command of the container.

View container information

There is such a command docker ps in Docker, you can view the information of the container, including container ID, base image, startup command, creation time, current status, port number, container name.

Create and start a container named firstContainer with the running environment of busybox. and output hello world.

#Create and start a container named firstContainer with the running environment of busybox. And output hello world 
#Pull the latest image of busybox
docker pull busybox
#********** Begin *********#
docker run  --name firstContainer busybox echo 'hello world'
#********** End **********#

Leave a Comment