Open zyhxq opened 8 years ago
查看linux操作系统版本 $cat /proc/version Linux version 2.6.32-220.23.2.XXX.el5.x86_64 (ads@localhost.localdomain) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Mon Jan 28 14:57:06 CST 201
说明操作系统是red hat系列,我们就可以装下载指定版本的docker啦
sudo yum remove docker
sudo yum remove docker*
安装alidocker sudo yum -b current install -y alidocker 删除 sudo yum remove alidocker*
安装原生docker sudo yum install docker-engine
$sudo service docker restart Restarting docker (via systemctl): Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. [FAILED]
$sudo setup-bridge nat TYPE=nat NETDEV=eth0 GATEWAY=192.168.5.1/24 DHCP=false
$sudo systemctl start docker Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
$ip link $brctl show bridge name bridge id STP enabled interfaces docker0 8000.0242c0a80501 no veth_natdummy
docker日志 /var/log/docker 安装网桥 sudo setup-bridge start
ip addr show eth0 ip route
启动mysql容器 sudo docker run --name mysql -v /var/lib/mysql -v /opt/fyun:/tmp/fyun -e MYSQL_ROOT_PASSWORD=hhhhhh -d mysql hxq1-6
Unable to find image 'mysql:latest' locally latest: Pulling from library/mysql 70e9a6907f10: Pull complete 32f2a4cccab8: Pull complete 941b42725941: Pull complete 9d1d3901c20a: Pull complete 7c88fa8d073b: Pull complete 7148ec0a1b6a: Pull complete 6d4e5d65fa7a: Pull complete 5c38331b8ed5: Pull complete 354d042e3175: Pull complete 5c4d4e18341e: Verifying Checksum d384b7b60269: Download complete d8cf53addf9e: Download complete bb932e31780f: Download complete 9ea1fef42552: Download complete cc5bed84d505: Download complete e2fd05a2f2e8: Download complete c607d9b50dfa: Download complete Pulling repository docker.io/library/mysql 4b95c7a7999d: Download complete 6b8a1ecb2364: Download complete d1cc0e6af849: Download complete ead4687593c9: Download complete ed4f1813feca: Download complete c8a74c850011: Download complete 442b95c21fda: Download complete 5c76f68081e0: Download complete 22baebd5561a: Download complete c2abe8008ef5: Download complete 95a24b8eb790: Download complete 834f127fbbb5: Download complete d4bd802efa23: Download complete f93fd9559f45: Download complete 842fc4629cd2: Download complete a1aad34da2f9: Download complete 571b0dbc7f16: Download complete Status: Image is up to date for mysql:latest docker.io/library/mysql: this image was pulled from a legacy registry. Important: This registry version will not be supported in future versions of docker. 2f3eacae74489b42258b1d88f2d84e0c46082ec8e679030878299092c371267b
$sudo docker build -t xiuqun.hxq/java8 -f java8.Dockerfile . Sending build context to Docker daemon 23.02 MB Step 1 : FROM ubuntu ---> c88b54fedc4f Step 2 : RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && add-apt-repository -y ppa:webupd8team/java && apt-get update && apt-get install -y oracle-java8-installer && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/oracle-jdk8-installer ---> Running in d74d94730691 /bin/sh: 1: add-apt-repository: not found The command '/bin/sh -c echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && add-apt-repository -y ppa:webupd8team/java && apt-get update && apt-get install -y oracle-java8-installer && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/oracle-jdk8-installer' returned a non-zero code: 127
$ sudo tee /etc/yum.repos.d/docker.repo <<-EOF [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7 enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF
spring boot docker化 $cat sb.dockerfile FROM williamyeh/java8 MAINTAINER xiuqun.hxq "junxiu_1218@126.com" ADD target/fyun-api-0.0.1-SNAPSHOT.jar /data/fyun-api.jar EXPOSE 8080 CMD ["java", "-jar", "/data/fyun-api.jar"]
创建xiuqun.hxq/fyun-api微服务镜像 $sudo docker build -t xiuqun.hxq/fyun-api -f fyun.dockerfile . Sending build context to Docker daemon 23.03 MB Step 1 : FROM williamyeh/java8 ---> cc882c0f00ad Step 2 : MAINTAINER xiuqun.hxq "junxiu_1218@126.com" ---> Running in cc5c72a9681b ---> fb9398bccd8c Removing intermediate container cc5c72a9681b Step 3 : ADD target/fyun-api-0.0.1-SNAPSHOT.jar /data/fyunapi.jar ---> b53ed69c5325 Removing intermediate container db09f3664c1a Step 4 : EXPOSE 8080 ---> Running in 1d1b08214d17 ---> 3ffa98e19903 Removing intermediate container 1d1b08214d17 Step 5 : CMD java -jar /data/fyunapi.jar ---> Running in 67e72d772a48 ---> bced8117a92b Removing intermediate container 67e72d772a48 Successfully built bced8117a92
启动fyun-api实例 sudo docker run -d -p 8080:8080 --name fyun-api8080 --link mysql:mysql xiuqun.hxq/fyun-api fe672c39262780520f7ec43f70fcf11cb08d146007dd1f409852a3cd4d6edd06 sudo docker run -d -p 8081:8080 --name fyun-api8081 --link mysql:mysql xiuqun.hxq/fyun-api 9f62f55d26424249ebb5528c78419a37bfa32a915d156f3aa5bcb05918f8f448 $sudo docker run -d -p 8082:8080 --name fyun-api8082 --link mysql:mysql xiuqun.hxq/fyun-api 5eba57219f637b0f6e4161fb83b56456e7fc8e028eaeae531cc879c623365450
删除容器 sudo docker rm -f containid
删除镜像 sudo docker rmi imageId
如: $sudo docker rmi 1757ff7c3619 Untagged: xiuqun.hxq/fyun-api:latest Deleted: 1757ff7c361905c9bfedda010e9a7402d1dcf21334ed53246b95d77b16c20e24 Deleted: 5bb40a4eba2a7aede612edf8710e7f0d69914505dddf9ea1cff682dc591c7d35 Deleted: dd656ae5c168e6499d16cdaca2de6f9985554a16eaf71f7b8c6f4bcf190c0847 Deleted: 1711c555b2d55cd77c6e5eacf9bb0396819d835ea9bef8ccb498c9182b900f19
docker我来晚啦!