首页 > 系统 > Linux >

docker入门操作

2017-06-19

docker入门操作。简单记录docker从镜像到启动命令包网络,磁盘,ip,容器名称,容器主机名称等指定。

docker入门操作

简单记录docker从镜像到启动命令包网络,磁盘,ip,容器名称,容器主机名称等指定
1.create a network of bridge
sudo docker network create -d bridge –subnet=1.1.1.0/24 mynetwork

2.access container,attach or exec or nsenter(No explanation)
sudo docker attach (dockerID or docker dockerName)
ps:this way of using attach is not perfect,because of syncing among a few windows

sudo docker exec -it (dockerID or docker dockerName) /bin/bash
ps:this is OK

3.create a docker based on “CENTOS7”,which some matters is bad,for example systemctl cannot work
sudo docker run -itd –privileged –network=mynetwork –hostname=mysql1 –ip=1.1.1.2 –name=mysql1 –volume=/docker/disks/mysql1:/mysql centos /usr/sbin/init

create container not based on CentOS7
sudo docker run -itd –network=mynetwork –hostname=mysql1 –ip=1.1.1.3 –name=jenkins –volume=/docker/disks/jenkins:/jenkins centos /bin/bash

4.ctl+p and ctl+q can switch operation bettwen background and foreground

相关文章
最新文章
热点推荐