In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The simplest to run the container:
Docker run image name docker run centos:v1 (this is the image name) docker run-dit-- name=c1 centos:v1 [root@docker ~] # docker tag hub.c.163.com/public/centos:6.7-tools centos:v1 [root@docker ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql latest b8fd9553f1f0 4 weeks ago 445 MBhub.c.163.com/library/mysql latest 9e64176cd8a2 2 years ago 407 MBcentos v1 b2ab0ed558bb 2 years ago 602 MBhub.c.163.com/public/centos 6.7-tools b2ab0ed558bb 2 years ago 602 MB
View the container that is running:
Docker ps
View all containers:
Docker ps-a
Run the container:
Docker run-t centos:v1
Provide an analog terminal, but cannot interact, so that the terminal in the container will not be closed and the container will not be closed.
Docker run-t-I centos:v1
Allow interaction
You can write: ```
Docker run-it centos:v1
When we run a container, if we do not specify what program the container runs, we default to run what the CMD at the top layer of the image refers to. We can replace the default program in the container with the specified command, such as:
[root@docker ~] # docker run centos:v1 / bin/bash
[root@docker] # docker ps-a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4bbd7c1810d1 centos:v1 "/ bin/bash" About a minute ago Exited (0) About a minute ago sleepy_spence
5be8fb481041 centos:v1 "/ usr/bin/supervisord" 17 minutes ago Up 17 minutes 22/tcp C1
If you execute docker run centos:v1 directly, you execute the CMD "/ usr/bin/supervisord" command, but we change the instruction to run / bin/bash. Because the / bin/bash life cycle is very short, execution completion is closed. You can specify different shell:
[root@docker ~] # cat / etc/shells
/ bin/sh
/ bin/bash
/ sbin/nologin
/ usr/bin/sh
/ usr/bin/bash
/ usr/sbin/nologin
/ bin/tcsh
/ bin/csh
[root@docker] # docker run-t-I centos:v1 / bin/sh
Sh-4.1# exit
Exit
[root@docker] # docker run-t-I centos:v1 / bin/bash
[root@53f96ebba145 /] #
When the program in the verification container ends, so does the container: the old section uses a CMD "/ bin/bash" image during the verification process, and the container ends as soon as the container runs. Docker run centos:v1 sleep 10 can observe that 10 seconds later, the container is also finished creating the container and defining the name docker run-- name=c1 centos:v1 stop / open / enter the j interactive container
Docker run-it-- name=c1 centos:v1 / bin/bash
Docker rm c1
Docker start c1
Docker attach c1
As long as exit the container, the container will be closed, how to exit and still keep the container? Docker run-it-- name=c1-- restart=always centos:v1 [root@docker ~] # docker run-it-- name=c3-- restart=always centos:v1 / bin/bash produces a large number of containers that are not running when frequently tested, and it is very troublesome to delete them one by one. We can add-- rmdocker run-it-- name=c1-- rm centos:v1docker run-it-- name=c3-- restart=always centos:v1 / bin/bash after running and exiting, docker ps-a will also automatically delete in the interactive environment. To change the hostname of the container, you can add-h name [root@docker ~] # docker run-it-- name=c3-- rm-h test centos:v1 / bin/bash [root@test /] # container to run in the background:-ddocker run-- it-d-- name=c1 centos:v1 exercise: in the development environment, python3 environment is required, but it is very troublesome to deploy and install python3 environment every time We can run the container implementation directly: 1 first find the image of python3: docker search pyhon3 or look for the image on NetEase Cloud / Ali Cloud. 2 download docker pull docker.io/sgoblin/python3.43 to view CMD:
[root@docker ~] # docker history docker.io/sgoblin/python3.4
IMAGE CREATED CREATED BY SIZE COMMENT
F01226b9a9cf 23 months ago / bin/sh-c # (nop) ENTRYPOINT ["/ bin/bash"] 0 B
23 months ago / bin/sh-c # (nop) CMD [] 0 B
23 months ago / bin/sh-c pip3 install-U virtualenv 3.86 MB
23 months ago / bin/sh-c ln-s / usr/bin/python3.4 / usr/b... 10.9 MB
23 months ago / bin/sh-c # (nop) ADD 79312a2a112b91c4ece7. 1.6 MB
23 months ago / bin/sh-c sed-I's MB archive.ubuntu.com
23 months ago / bin/sh-c # (nop) MAINTAINER Ryan M.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.