Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample code for command in docker

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article shares with you the content of the sample code for command in docker. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

# command

# install docker in ubuntu 14sudo apt-get install docker.iosudo docker pull ubuntusudo docker pull ubuntu:14.04sudo docker run-t-I ubuntu / bin/bashsudo docker imagessudo docker ps sudo docker ps-asudo docker ps-lsudo docker inspect [image id] sudo docker search mysqlsudo docker rmi [- f] [image id or tag] # start the container (stopped) sudo docker start [docker name] # enter sudo docker attach [docker name] # enter the container console using bash, bash can be replaced with sh That is, when you create a new container with shsudo docker exec-it bash#, you need to specify the domain name of the container and the hosts file # Parameter: # name: container name # h: domain name # the mapping between the domain name in the add-host:/etc/hosts file and IP docker run-- name cloud1-h cloud1-- add-host cloud1:172.17.0.2-- add-host cloud2:172.17.0.3-- add-host cloud3:172.17.0.4-it ubuntu# submits the cloud1 container Command returns the new image number docker commit cloud1# to label the new image as Sparkdocker tag / [(default:) latest] # login, default docker hubdocker login#logoutdocker logout# pushdocker push /: # View docker network docker network ls# install ping in the container, run apt-get updateapt-get install iputils-ping# in the container to install ifconfig in the container, run apt-get updateapt-get install net-tools# in the container to install telnet in the container Run apt-get install telnet#-v in the container to mount the local directory / home/docker/software/ to the / software directory in the container. The path permission for docker run-v / home/docker/software/:/software-it ubuntu# mounting is read and write by default. If specified as read-only, use: rodocker run-v / home/docker/software/:/software:ro-it ubuntu# to view container's ipdocker inspect-- format "{{.NetworkSettings.IPAddress}}" container-name# launches three spark (ubuntu) containers docker run-- name cloud1-h cloud1-- add-host cloud1:172.17.0.2-- add-host cloud2:172.17.0.3-- add-host cloud3:172.17.0.4-it ubuntuproblem

Install ssh

Error:

Root@cloud1:~# ssh root@cloud1ssh: connect to host cloud1 port 22: Connection refusedroot@cloud1:~# source. / .bashrc Missing privilege separation directory: / var/run/sshd

Solution:

Mkdir / var/run/sshdchmod 0755 / var/run/sshd

Modify parameters

Once the docker container is started, the parameters cannot be changed. awkward.

# source ~ / .bashrc sh: 14: source: not found

Command prompt in ubuntu-upstart? Is #, and shell is dash. Enter "bash" to switch to bash environment, and the source command can be used normally.

Thank you for reading! This is the end of this article on "sample code for command in docker". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report