官术网_书友最值得收藏!

Creating containers

Launching a container is simple, as docker run passes the image name you would like to run and the command to run this within the container. If the image doesn't exist on your local machine, Docker will attempt to fetch it from the public image registry:

$ sudo docker run --name hello_world ubuntu /bin/echo hello world  

In the preceding example, the container will start, print hello world, and then stop. Containers are designed to stop once the command executed within them has exited.

As an example, let's run a container using the latest image in Ubuntu. The combination of the -i and -t switches gives you interactive shell access to the container:

$ sudo docker run -it ubuntu
root@a5b3bce6ed1b:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  
run sbin srv sys tmp usr var
主站蜘蛛池模板: 新野县| 清丰县| 册亨县| 农安县| 成都市| 富裕县| 孝感市| 任丘市| 霍山县| 丹棱县| 景东| 宿迁市| 日喀则市| 靖州| 拜泉县| 阿克苏市| 鄂托克旗| 新田县| 宝兴县| 开江县| 江油市| 华宁县| 鄂温| 鄂温| 密云县| 怀来县| 乌鲁木齐市| 甘孜| 高州市| 建德市| 百色市| 夹江县| 克东县| 武鸣县| 将乐县| 三穗县| 宁安市| 盐源县| 汪清县| 东兰县| 区。|