"Docker Command"-run command

Source: Internet
Author: User
Tags docker run

Docker run: Create a new container and run a command

Grammar:

Docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Options Description:

  • -A stdin: Specifies the standard input and output content type, optional stdin/stdout/stderr three items;

  • - D: run the container in the background and return the container ID;

  • -I : run the container in interactive mode, usually in conjunction with-t;

  • - P: port mapping in the format: host (host) port: Container Port

  • - T: reallocate a pseudo-input terminal to the container, usually with-I;

  • --name= "nginx-lb": Specify a name for the container;

  • --dns 8.8.8.8: Specifies the DNS server used by the container, default and host consistent;

  • --dns-search example.com: Specifies the container DNS search domain name, default and host consistent;

  • - H "Mars": Specifies the hostname of the container;

  • - e Username= "Ritchie": setting environment variables;

  • --env-file=[]: reads from the specified file into the environment variable;

  • --cpuset= "0-2" or--cpuset= "0,1,2": binds the container to the specified CPU to run;

  • - m: sets the maximum amount of memory used by the container;

  • --net= "Bridge": Specifies the network connection type of the container, supports the bridge/host/none/container:<name|id> four types;

  • --link=[]: add link to another container;

  • --expose=[]: open a port or a set of ports;

Instance

Use Docker image nginx:latest to start a container in background mode and name the container Mynginx:

Docker Run--name mynginx-d nginx:latest

Use mirror nginx:latest to start a container in background mode and map the container's 80 port to the host random port:

Docker Run-p-D nginx:latest

Using mirrored nginx:latest, start a container in background mode, map the container's 80 port to the host's 80 port, and the host's directory/data map to the/data of the container:

Docker run-p 80:80-v/data:/data-d nginx:latest

Bind the container's 8080 port and map it to port 80 on the local host 127.0.0.1:

Docker run-p 127.0.0.1:80:8080/tcp Ubuntu bash

Use mirror nginx:latest to start a container in interactive mode and execute the/bin/bash command inside the container:

Docker run-it Nginx:latest/bin/bash

"Docker Command"-run command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.