In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the use of Docker skills, the article is very detailed, has a certain reference value, interested friends must read it!
Get the ID of the last executed container
$ID=$ (docker run ubuntu echo hello world) hello world $docker commit $ID helloword
If you find it troublesome, you can do this:
$alias dl='docker ps-l-q' $docker run ubuntu echo hello word helloworld $dl 1904cf045887 $docker commit `dl` helloworld fd08a884dc79
Try to make a Docker image in shell
$docker run-I-t ubuntu bash root@db0c3978af8:/# apt-get install postgresql root@db0c3978af8:/# exit $docker commit-run=' {"Cmd": ["postgres", "- too-many-opts"]} '`dl` postgres 507611232efc0
Remove sudo
# add docker group $sudo groupadd docker # add yourself to the group $sudo gpasswd-a myusername docker # restart the Docker daemon $sudo service docker restart # exit and log in to $exit
Delete all containers that have been stopped
$docker rm $(docker ps-a-Q)
Convert docker inspect output
$docker inspect `dl` | grep IPAddress | cut-d'"'- f 4 172.17.0.52$ docker inspect `dl1` | jq-r'. [0] .NetworkSettings.IPAddress' 172.17.0.52
Check what are the environment variables in the image
$docker run ubuntu env HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin container=lxc HOSTNAME=5e150b7fef22
The difference between RUN and CMD
FROM ubuntu # executes the following when executing docker build: RUN apt-get update RUN apt-get install softwres # executes the default execution when executing docker run: CMD ["softwares"]
The difference between CMD and ENTRYPOINT
$cat Dockerfile FROM ubuntu CMD ["echo"] $coker run imagename echo hello hello $cat Dockerfile FROM ubuntu ENTRYPOINT ["echo"] $coker run imagename echo hello echo hello
View the IP of the Docker container
$ip-4-o addr show eth0 2: eth0 inet 10.108.1.107 scope global eth0 24 brd 10.108.1.255 scope global eth0 $docker run ubuntu ip-4-o addr show eth0 83: eth0 inet 172.17.0.4 o addr show eth0 16 scope global eth0
Docker architecture: a thin CLI client, a daemon that provides REST services based on UNIX socket
# Connect and use UNIX socket $nc-U / / var/run/docker.sock GET / images/json HTTP/1.1 like a HTTP client
Note: I carried out this order and there was no response. I don't know why.
View the dependence of your mirror image as an image
$docker images-viz | dot-Tpng-o docker.png $python-m SimpleHTTPServer # Open browser # http://machinename:8000/docker.png
Note: the individual doesn't quite understand here.
Where exactly are Docker's things stored?
$sudo su # cd / var/lib/docker # ls-F containers/ graph/ repositories volumes/
Graph stores images, while graph/imagesid/layer exists in the file system
Docker source code
Commands.go is responsible for the command line client
Api.go REST API routing
The implementation of a REST API in server.go
Parser for buildfile.go Dockerfile
Do not execute daemons in RUN instructions in your Dockerfile
$cat Dockerfile FROM ubuntu:12.04 MAINTAINER Brian Morearty.. RUN pg_ctl start... $docker run-I-t postgresimage bash root@4432fe2dd3:/# ps aux # Doesn't show postgres daemon
Note: in fact, you can do RUN pg_ctl start &
Communication between containers # executes a container and assigns it a name $docker run-d-name loldb loldbimage
# execute the second container and connect to the first container, using the alias $docker run-link / loldb:cheez otherimage env CHEEZ_PORT=tcp://172.17.0.8:6379 CHEEZ_PORT_1337_TCP=tcp://172.17.0.8:6379 CHEEZ_PORT_1337_TCP_ADDR=172.17.0.12 CHEEZ_PORT_1337_TCP_PORT=6379 CHEEZ_PORT_1337_TCP_PROTO=tcp
Note: I don't quite understand the meaning of the env shown.
These are all the contents of this article entitled "what are the skills in Docker?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.