1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > docker 删除映像_创建自己的Docker映像(技术提示#57)

docker 删除映像_创建自己的Docker映像(技术提示#57)

时间:2018-12-05 07:58:52

相关推荐

docker 删除映像_创建自己的Docker映像(技术提示#57)

docker 删除映像

Docker通过轻松构建和共享包含应用程序整个环境的映像来简化软件交付,例如,操作系统,JDK,数据库,WAR文件,应用程序所需的特定调整等。

Docker包含三个主要组件:

Docker映像是“构建组件” –应用程序操作系统的只读模板。 容器是“运行组件” –从映像创建的运行时表示。 注册表是“分发组件” –存储和分发映像的地方。

可在/docker上以Docker映像的形式获得几个JBoss项目。 技术提示39说明了如何在Mac上使用Docker。 它还说明了如何启动正式的WildFly Docker映像 。

Docker映像由多层组成,其中每一层都提供某些功能,而更高的层可以在其之上添加功能。 例如,Docker将根文件系统挂载为只读层,然后在其之上添加一个读写层。 使用Union Mount将所有这些层组合在一起,以提供应用程序操作环境。

关于WildFly图像构建方式的完整历史可以看成是:

docker history --no-trunc=true jboss/wildflyIMAGE CREATED CREATED BY SIZE365390553f925f96f8c00f79525ad101847de7781bb4fec23b1188f25fe99a6a 3 weeks ago /bin/sh -c #(nop) CMD [/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0] 0 Bd7fccab36b8f5a324ef8dd017c8964f2de7839379503021f15502ba3f0b908bd 3 weeks ago /bin/sh -c #(nop) EXPOSE map[8080/tcp:{} 9990/tcp:{}]0 B184d6d02f340455d33d226d6467484027d0763964a586ae9ada1782262299a74 3 weeks ago /bin/sh -c #(nop) ENV JBOSS_HOME=/opt/jboss/wildfly 0 B57ada25ecdd03191355ec1c8f5f1a4e05b3e152709c9b603d5ed5fb0c4d53853 3 weeks ago /bin/sh -c cd $HOME && curl /wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly 135 MB59ec65b61fba2b6ada099abe3a9a30d05ffb71370b43dfbd0208fd4f5a34c005 3 weeks ago /bin/sh -c #(nop) ENV WILDFLY_VERSION=8.1.0.Final 0 B90832e1f0bb9e9f98ecd42f6df6b124c1e6768babaddc23d646cd75c7b2fddec 5 weeks ago /bin/sh -c #(nop) ENV JAVA_HOME=/usr/lib/jvm/java 0 B72d585299bb5c5c1c326422cfffadc93d8bb4020f35bf072b2d91d287967807a 5 weeks ago /bin/sh -c #(nop) USER jboss0 Be02bdb6c4ed5436da02c958d302af5f06c1ebb1821791f60d45e190ebb55130f 5 weeks ago /bin/sh -c yum -y install java-1.7.0-openjdk-devel && yum clean all217.2 MBb17a20d6f5f8e7ed0a1dba277acd3f854c531b0476b03d63a8f0df4caf78c763 5 weeks ago /bin/sh -c #(nop) USER root0 B7759146eab1a3aa5ba5ed12483d03e64a6bf1061a383d5713a5e21fc40554457 5 weeks ago /bin/sh -c #(nop) MAINTAINER Marek Goldmann0 B2ea8562cac7c25a308b4565b66d4f7e11a1d2137a599ef2b32ed23c78f0a0378 5 weeks ago /bin/sh -c #(nop) USER jboss0 B4d37cbbfc67dd508e682a5431a99d8c1feba1bd8352ffd3ea794463d9cfa81cc 5 weeks ago /bin/sh -c #(nop) WORKDIR /opt/jboss 0 B379edb00ab0764276787ea777243990da697f2f93acb5d9166ff73ad01511a87 5 weeks ago /bin/sh -c groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss295 kBcd5bb934bb6755e910d19ac3ae4cfd09221aa2f98c3fbb51a7486991364dc1ae 5 weeks ago /bin/sh -c yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all 21.35 MB20a1abe1d9bfb9b1e46d5411abd5a38b6104a323b7c4fb5c0f1f161b8f7278c2 5 weeks ago /bin/sh -c yum -y update && yum clean all 200.7 MB1ef0a50fe8b1394d3626a7624a58b58cff9560ddb503743099a56bbe95ab481a 5 weeks ago /bin/sh -c #(nop) MAINTAINER Marek Goldmann 0 B7d3f07f8de5fb3a20c6cb1e4447773a5741e3641c1aa093366eaa0fc690c6417 7 weeks ago /bin/sh -c #(nop) ADD file:285fdeab65d637727f6b79392a309135494d2e6046c6cc2fbd2f23e43eaac69c in / 374.1 MB782cf93a8f16d3016dae352188cd5cfedb6a15c37d4dbd704399f02d1bb89dab 7 weeks ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar - ./buildcontainers.sh0 B511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 17 months ago0 B

在此输出中列出了在每一层发出的确切命令。 如果滚动到最右边,那么您还可以看到每个图层占用的总空间。 例如,Fedora用作基本映像,消耗了约574 MB的总映像,Open JDK 7占用了217.5 MB,WildFly则是135 MB。

通过阅读Dockerfile的指令来构建Docker映像。 这是一个文本文件,按顺序包含构建给定图像所需的所有命令。 它遵循特定的格式并使用一组特定的说明。 命令的词汇量非常有限,但可以很好地达到目的。 可以通过提供命令docker build来构建映像。 Docker Tutorial提供了有关如何创建自己的自定义映像的完整说明。

官方的WildFly Docker映像是使用Fedora 20作为基本操作系统构建的。 可以在/jboss-dockerfiles/wildfly/blob/master/Dockerfile上找到Dockerfile 。 它使用jboss / base-jdk:7作为基础映像,而使用jboss / base作为基础映像。 jboss / base的Dockerfile显示Fedora 20被用作基础映像。

一种替代方法是使用CentOS或Ubuntu作为基础映像来构建该映像。DockerfileS表示这些图像可在/arun-gupta/docker-images/ 。

启动boot2docker将输出显示为:

bashunset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATHmkdir -p ~/.boot2dockerif [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi/usr/local/bin/boot2docker init /usr/local/bin/boot2docker up $(/usr/local/bin/boot2docker shellinit)docker versionLast login: Mon Nov 24 11:03:33 on ttys006hello arungupta~> bash~> unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH~> mkdir -p ~/.boot2docker~> if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi~> /usr/local/bin/boot2docker init Virtual machine boot2docker-vm already exists~> /usr/local/bin/boot2docker up Waiting for VM and Docker daemon to start........................oooooooooooooooooStarted.Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pemWriting /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pemWriting /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pemTo connect the Docker client to the Docker daemon, please set:export DOCKER_HOST=tcp://192.168.59.103:2376export DOCKER_CERT_PATH=/Users/arungupta/.boot2docker/certs/boot2docker-vmexport DOCKER_TLS_VERIFY=1~> $(/usr/local/bin/boot2docker shellinit)Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pemWriting /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pemWriting /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pem~> docker versionClient version: 1.3.1Client API version: 1.15Go version (client): go1.3.3Git commit (client): 4e9bbfaOS/Arch (client): darwin/amd64Server version: 1.3.1Server API version: 1.15Go version (server): go1.3.3Git commit (server): 4e9bbfa

然后,您可以构建基于CentOS的WildFly Docker映像,如下所示。 请注意,此命令是从/arun-gupta/docker-images/的“ wildfly-centos”目录中给出的 。 因此,Dockerfile位于/arun-gupta/docker-images/blob/master/wildfly-centos/Dockerfile 。

wildfly-centos> docker build -t wildfly-centos .Sending build context to Docker daemon 4.096 kBSending build context to Docker daemon Step 0 : FROM centoscentos:latest: The image you are pulling has been verified511136ea3c5a: Pull complete 5b12ef8fd570: Pull complete ae0c2d0bdc10: Pull complete Status: Downloaded newer image for centos:latest---> ae0c2d0bdc10Step 1 : MAINTAINER Arun Gupta <arungupta@>---> Running in 7fc52653d381---> e490dfcb3685Removing intermediate container 7fc52653d381Step 2 : RUN yum -y update && yum clean all---> Running in 90de23c9dde7Loaded plugins: fastestmirrorDetermining fastest mirrors* base: .columbia.edu* extras: centos.* updates: centos-Resolving Dependencies--> Running transaction check---> Package tzdata.noarch 0:h-1.el7 will be updated---> Package tzdata.noarch 0:j-1.el7_0 will be an update--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Updating:tzdatanoarchj-1.el7_0 updates434 kTransaction Summary================================================================================Upgrade 1 PackageTotal download size: 434 kDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.warning: /var/cache/yum/x86_64/7/updates/packages/tzdata-j-1.el7_0.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPublic key for tzdata-j-1.el7_0.noarch.rpm is not installedRetrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5:Userid: "CentOS-7 Key (CentOS 7 Official Signing Key) <security@>"Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package : centos-release-7-0.1406.el7.centos.2.5.x86_64 (@Updates/$releasever)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating : tzdata-j-1.el7_0.noarch 1/2 Cleanup : tzdata-h-1.el7.noarch2/2 Verifying : tzdata-j-1.el7_0.noarch 1/2 Verifying : tzdata-h-1.el7.noarch2/2 Updated:tzdata.noarch 0:j-1.el7_0 Complete!Loaded plugins: fastestmirrorCleaning repos: base extras updatesCleaning up everythingCleaning up list of fastest mirrors---> f212cb9dbcf5Removing intermediate container 90de23c9dde7Step 3 : RUN yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all---> Running in d4bd822933c8Loaded plugins: fastestmirrorDetermining fastest mirrors* base: mirror-* extras: * updates: No package xmlstarlet available.Resolving Dependencies--> Running transaction check---> Package augeas.x86_64 0:1.1.0-12.el7 will be installed--> Processing Dependency: augeas-libs = 1.1.0-12.el7 for package: augeas-1.1.0-12.el7.x86_64. . .--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-6.el7_0.noarch--> Running transaction check---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch VersionRepository Size================================================================================Installing:augeas x86_641.1.0-12.el7 base35 kbsdtar x86_643.1.2-7.el7 base55 k. . .python-javapackagesnoarch3.4.1-6.el7_0updates 31 kpython-lxml x86_643.2.1-4.el7 base 758 kTransaction Summary================================================================================Install 4 Packages (+9 Dependent packages)Total download size: 4.2 MInstalled size: 8.0 MDownloading packages:--------------------------------------------------------------------------------Total188 kB/s | 4.2 MB 00:22Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling : lzo-2.06-6.el7_0.2.x86_641/13 Installing : libxslt-1.1.28-5.el7.x86_64 . . .Installing : unzip-6.0-13.el7.x86_6413/13 Verifying : augeas-1.1.0-12.el7.x86_64 1/13 . . .Verifying : javapackages-tools-3.4.1-6.el7_0.noarch13/13 Installed:augeas.x86_64 0:1.1.0-12.el7 bsdtar.x86_64 0:3.1.2-7.el7saxon.noarch 0:9.3.0.4-11.el7 unzip.x86_64 0:6.0-13.el7 Dependency Installed:augeas-libs.x86_64 0:1.1.0-12.el7 bea-stax.noarch 0:1.2.0-9.el7 bea-stax-api.noarch 0:1.2.0-9.el7 javapackages-tools.noarch 0:3.4.1-6.el7_0 libarchive.x86_64 0:3.1.2-7.el7 libxslt.x86_64 0:1.1.28-5.el7 lzo.x86_64 0:2.06-6.el7_0.2 python-javapackages.noarch 0:3.4.1-6.el7_0 python-lxml.x86_64 0:3.2.1-4.el7 Complete!Loaded plugins: fastestmirrorCleaning repos: base extras updatesCleaning up everythingCleaning up list of fastest mirrors---> 28b11e6151f0Removing intermediate container d4bd822933c8Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss---> Running in 943c20ba5a51---> 73603eab89b7Removing intermediate container 943c20ba5a51Step 5 : WORKDIR /opt/jboss---> Running in 29c865c3109c---> 9a661ae4341bRemoving intermediate container 29c865c3109cStep 6 : USER jboss---> Running in 7dfd8416ae2c---> 6265153611c7Removing intermediate container 7dfd8416ae2cStep 7 : USER root---> Running in a72588fba840---> 12ed28a7acb7Removing intermediate container a72588fba840Step 8 : RUN yum -y install java-1.7.0-openjdk-devel && yum clean all---> Running in 4efb3e17eb38Loaded plugins: fastestmirrorDetermining fastest mirrors* base: mirror.trouble-* extras: centos.* updates: centos-Resolving Dependencies--> Running transaction check---> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0 will be installed. . .---> Package hwdata.noarch 0:0.252-7.3.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch VersionRepositorySize================================================================================Installing:java-1.7.0-openjdk-develx86_64 1:1.7.0.71-2.5.3.1.el7_0 updates 9.2 MInstalling for dependencies:alsa-lib x86_64 1.0.27.2-3.el7 base389 k. . .144 kxorg-x11-font-utilsx86_64 1:7.5-18.1.el7 base87 kxorg-x11-fonts-Type1 noarch 7.5-9.el7 base521 kTransaction Summary================================================================================Install 1 Package (+73 Dependent packages)Total download size: 49 MInstalled size: 181 MDownloading packages:--------------------------------------------------------------------------------Total1.7 MB/s | 49 MB 00:29Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling : freetype-2.4.11-9.el7.x86_64 1/74 Installing : libjpeg-turbo-1.2.90-5.el7.x86_64 2/74 . . .73/74 Installing : 1:java-1.7.0-openjdk-devel-1.7.0.71-2.5.3.1.el7_0.x86_64 74/74 Verifying : libsndfile-1.0.25-9.el7.x86_641/74 Verifying : libXfont-1.4.7-2.el7_0.x86_64 2/74 Verifying : kmod-14-9.el7.x86_64. . .73/74 Verifying : gdk-pixbuf2-2.28.2-4.el7.x86_64 74/74 Installed:java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0 Dependency Installed:alsa-lib.x86_64 0:1.0.27.2-3.el7atk.x86_64 0:2.8.0-4.el7 . . .xorg-x11-font-utils.x86_64 1:7.5-18.1.el7 xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 Complete!Loaded plugins: fastestmirrorCleaning repos: base extras updatesCleaning up everythingCleaning up list of fastest mirrors---> 44c4bb92fa11Removing intermediate container 4efb3e17eb38Step 9 : USER jboss---> Running in 824d62c49182---> 930cb2a860f7Removing intermediate container 824d62c49182Step 10 : ENV JAVA_HOME /usr/lib/jvm/java---> Running in f19681365fe5---> fff2c21b0a71Removing intermediate container f19681365fe5Step 11 : ENV WILDFLY_VERSION 8.2.0.Final---> Running in cc9d42ece5c1---> b7b7ca7a9172Removing intermediate container cc9d42ece5c1Step 12 : RUN cd $HOME && curl -O /wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip---> Running in 28e92a1b304f% Total % Received % Xferd Average Speed Time TimeTime CurrentDload Upload Total Spent Left Speed100 126M 100 126M 00 813k0 0:02:38 0:02:38 --:--:-- 644kArchive: wildfly-8.2.0.Final.zipcreating: wildfly-8.2.0.Final/creating: wildfly-8.2.0.Final/.installation/creating: wildfly-8.2.0.Final/appclient/creating: wildfly-8.2.0.Final/appclient/configuration/creating: wildfly-8.2.0.Final/bin/. . .inflating: wildfly-8.2.0.Final/domain/configuration/application-users.properties inflating: wildfly-8.2.0.Final/domain/configuration/mgmt-users.properties inflating: wildfly-8.2.0.Final/standalone/configuration/application-users.properties inflating: wildfly-8.2.0.Final/standalone/configuration/mgmt-users.properties creating: wildfly-8.2.0.Final/domain/tmp/auth/creating: wildfly-8.2.0.Final/standalone/tmp/auth/---> a1bc79a43c77Removing intermediate container 28e92a1b304fStep 13 : ENV JBOSS_HOME /opt/jboss/wildfly---> Running in e3c995170046---> d46fdd618d55Removing intermediate container e3c995170046Step 14 : EXPOSE 8080 9990---> Running in d55d6a6f43cf---> 6c17e2cefecfRemoving intermediate container d55d6a6f43cfStep 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0---> Running in 76e2630d16f5---> 97c8780a7d6aRemoving intermediate container 76e2630d16f5Successfully built 97c8780a7d6a

现在可以将Docker映像列表视为:

wildfly-centos> docker imagesREPOSITORYTAG IMAGE ID CREATED VIRTUAL SIZEwildfly-centoslatest 97c8780a7d6a 58 seconds ago619.6 MBcentos latest ae0c2d0bdc10 2 weeks ago 224 MB

总图像大小为619.6 MB。 可以如下所示安装正式的WildFly Docker映像:

wildfly-centos> docker pull jboss/wildflyPulling repository jboss/wildfly365390553f92: Download complete 511136ea3c5a: Download complete 782cf93a8f16: Download complete 7d3f07f8de5f: Download complete 1ef0a50fe8b1: Download complete 20a1abe1d9bf: Download complete cd5bb934bb67: Download complete 379edb00ab07: Download complete 4d37cbbfc67d: Download complete 2ea8562cac7c: Download complete 7759146eab1a: Download complete b17a20d6f5f8: Download complete e02bdb6c4ed5: Download complete 72d585299bb5: Download complete 90832e1f0bb9: Download complete 59ec65b61fba: Download complete 57ada25ecdd0: Download complete 184d6d02f340: Download complete d7fccab36b8f: Download complete Status: Downloaded newer image for jboss/wildfly:latest

Docker映像的完整列表可以再次视为:

wildfly-centos> docker imagesREPOSITORYTAG IMAGE ID CREATED VIRTUAL SIZEwildfly-centoslatest 97c8780a7d6a 12 minutes ago619.6 MBcentos latest ae0c2d0bdc10 2 weeks ago 224 MBjboss/wildfly latest 365390553f92 4 weeks ago 948.7 MB

在这种情况下,图像大小为948.7 MB。 在此博客的前面已解释了如何创建此图像的详细信息。

可以如下所示构建和安装基于Ubuntu的WildFly映像。 请注意,此命令是从/arun-gupta/docker-images/的“ wildfly-ubuntu”目录中给出的 。 因此,Dockerfile位于/arun-gupta/docker-images/blob/master/wildfly-ubuntu/Dockerfile 。

wildfly-ubuntu> docker build -t wildfly-ubuntu .Sending build context to Docker daemon 4.096 kBSending build context to Docker daemon Step 0 : FROM ubuntuubuntu:latest: The image you are pulling has been verifiedd497ad3926c8: Pull complete ccb62158e970: Pull complete e791be0477f2: Pull complete 3680052c0f5c: Pull complete 22093c35d77b: Pull complete 5506de2b643b: Pull complete 511136ea3c5a: Already exists Status: Downloaded newer image for ubuntu:latest---> 5506de2b643bStep 1 : MAINTAINER Arun Gupta---> Running in cc444b436b26---> 9df66d33d676Removing intermediate container cc444b436b26Step 2 : RUN apt-get update---> Running in 3dc63c0f708aIgn trusty InReleaseIgn trusty-updates InReleaseIgn trusty-security InReleaseIgn trusty-proposed InReleaseGet:1 trusty Release.gpg [933 B]Get:2 trusty-updates Release.gpg [933 B]Get:3 trusty-security Release.gpg [933 B]Get:4 trusty-proposed Release.gpg [933 B]Get:5 trusty Release [58.5 kB]Get:6 trusty-updates Release [62.0 kB]Get:7 trusty-security Release [62.0 kB]Get:8 trusty-proposed Release [209 kB]Get:9 trusty/main Sources [1335 kB]Get:10 trusty/restricted Sources [5335 B]Get:11 trusty/universe Sources [7926 kB]Get:12 trusty/main amd64 Packages [1743 kB]Get:13 trusty/restricted amd64 Packages [16.0 kB]Get:14 trusty/universe amd64 Packages [7589 kB]Get:15 trusty-updates/main Sources [179 kB]Get:16 trusty-updates/restricted Sources [1250 B]Get:17 trusty-updates/universe Sources [114 kB]Get:18 trusty-updates/main amd64 Packages [465 kB]Get:19 trusty-updates/restricted amd64 Packages [6341 B]Get:20 trusty-updates/universe amd64 Packages [286 kB]Get:21 trusty-security/main Sources [62.7 kB]Get:22 trusty-security/restricted Sources [40 B]Get:23 trusty-security/universe Sources [19.1 kB]Get:24 trusty-security/main amd64 Packages [205 kB]Get:25 trusty-security/restricted amd64 Packages [40 B]Get:26 trusty-security/universe amd64 Packages [93.4 kB]Get:27 trusty-proposed/main amd64 Packages [193 kB]Get:28 trusty-proposed/restricted amd64 Packages [40 B]Fetched 20.6 MB in 43s (469 kB/s)Reading package lists...---> 7fcaaf17b124Removing intermediate container 3dc63c0f708aStep 3 : RUN apt-get -y install xmlstarlet bsdtar unzip curl---> Running in 81613b0e3b71Reading package lists...Building dependency tree...Reading state information...The following extra packages will be installed:ca-certificates krb5-locales libarchive13 libasn1-8-heimdal libcurl3libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal. . .Updating certificates in /etc/ssl/certs... 164 added, 0 removed; done.Running hooks in /etc/ca-certificates/update.d....done.Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...---> 0d897d545547Removing intermediate container 81613b0e3b71Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss---> Running in bf31e0e1f448---> 7494e71043c0Removing intermediate container bf31e0e1f448Step 5 : WORKDIR /opt/jboss---> Running in 1ac355c74395---> abbbb6aa6b71Removing intermediate container 1ac355c74395Step 6 : USER jboss---> Running in a656007f6e6b---> 657671b82d0fRemoving intermediate container a656007f6e6bStep 7 : USER root---> Running in f53138927d04---> d3bd53152a51Removing intermediate container f53138927d04Step 8 : RUN apt-get -y install openjdk-7-jdk---> Running in 1076b257c6f6Reading package lists...Building dependency tree...Reading state information...The following extra packages will be installed:acl at-spi2-core ca-certificates ca-certificates-java colord cpp cpp-4.8dbus dbus-x11 dconf-gsettings-backend dconf-service desktop-file-utils. . .Adding debian:Wells_Fargo_Root_CA.pemAdding debian:XRamp_Global_CA_Root.pemAdding debian:certSIGN_ROOT_CA.pemAdding debian:ePKI_Root_Certification_Authority.pemAdding debian:thawte_Primary_Root_CA.pemAdding debian:thawte_Primary_Root_CA_-_G2.pemAdding debian:thawte_Primary_Root_CA_-_G3.pemAdding debian:spi-cacert-.pemdone.done.---> 558f23c93a8cRemoving intermediate container 1076b257c6f6Step 9 : USER jboss---> Running in 9d6955bcd19f---> 7f16c426ccafRemoving intermediate container 9d6955bcd19fStep 10 : ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64---> Running in 66f22bd0de95---> 6304f386c946Removing intermediate container 66f22bd0de95Step 11 : ENV WILDFLY_VERSION 8.2.0.Final---> Running in 784e1533fa09---> 1a5e1aeadc85Removing intermediate container 784e1533fa09Step 12 : RUN cd $HOME && curl -O /wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip---> Running in c7d808526af6% Total % Received % Xferd Average Speed Time TimeTime CurrentDload Upload Total Spent Left Speed100 126M 100 126M 00 993k0 0:02:09 0:02:09 --:--:-- 870kArchive: wildfly-8.2.0.Final.zipcreating: wildfly-8.2.0.Final/. . .inflating: wildfly-8.2.0.Final/standalone/configuration/mgmt-users.properties creating: wildfly-8.2.0.Final/domain/tmp/auth/creating: wildfly-8.2.0.Final/standalone/tmp/auth/---> 551e8b1db275Removing intermediate container c7d808526af6Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly---> Running in 7709c6f468ef---> 0cec4b9ccd6bRemoving intermediate container 7709c6f468efStep 14 : EXPOSE 8080 9990---> Running in dd053271b09e---> 0281986b0ed8Removing intermediate container dd053271b09eStep 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0---> Running in fb29091de599---> 6a1c4acf3f78Removing intermediate container fb29091de599Successfully built 6a1c4acf3f78

Docker映像列表可以再次视为:

wildfly-ubuntu> docker imagesREPOSITORYTAG IMAGE ID CREATED VIRTUAL SIZEwildfly-ubuntulatest 6a1c4acf3f78 5 minutes ago 749.5 MB<none> <none> 1a5e1aeadc85 13 minutes ago607.7 MBwildfly-centoslatest 97c8780a7d6a About an hour ago 619.6 MBcentos latest ae0c2d0bdc10 2 weeks ago 224 MBjboss/wildfly latest 365390553f92 4 weeks ago 948.7 MBubuntu latest 5506de2b643b 4 weeks ago 199.3 MB

Docker映像可以使用docker run命令docker run。 其他一些相关的命令是:

docker ps:列出容器docker stop <id>:使用给定的<id>停止容器

如下所示运行CentOS映像。 指定-i选项将使其具有交互性,而-t选项将分配伪TTY。 并且可以在容器的端口80上访问来自容器的端口8080。

~> docker run -i -t -p 80:8080 wildfly-centos=========================================================================JBoss Bootstrap EnvironmentJBOSS_HOME: /opt/jboss/wildflyJAVA: /usr/lib/jvm/java/bin/javaJAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true=========================================================================22:20:52,769 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final22:20:53,038 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final22:20:53,120 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting22:20:54,176 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)22:20:54,197 INFO [org.xnio] (MSC service thread 1-10) XNIO version 3.3.0.Final22:20:54,206 INFO [org.xnio.nio] (MSC service thread 1-10) XNIO NIO Implementation Version 3.3.0.Final22:20:54,239 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors22:20:54,265 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.22:20:54,302 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem22:20:54,314 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.22:20:54,345 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]22:20:54,363 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem22:20:54,374 INFO [org.jboss.as.security] (MSC service thread 1-8) JBAS013170: Current PicketBox version=4.0.21.Final22:20:54,419 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension22:20:54,486 INFO [org.jboss.as.connector.logging] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)22:20:54,573 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017502: Undertow 1.1.0.Final starting22:20:54,579 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting22:20:54,586 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)22:20:54,644 INFO [org.jboss.remoting] (MSC service thread 1-10) JBoss Remoting version 4.0.6.Final22:20:54,658 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010417: Started Driver service with driver-name = h222:20:54,763 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service22:20:54,761 INFO [org.jboss.as.mail.extension] (MSC service thread 1-16) JBAS015400: Bound mail session 22:20:56,387 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content22:20:56,422 INFO [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017525: Started server default-server.22:20:56,544 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017531: Host default-host starting22:20:56,712 INFO [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:808022:20:56,975 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-14) JBAS010400: Bound data source 22:20:56,976 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-15) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments22:20:57,172 INFO [org.mon.management] (MSC service thread 1-10) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final22:20:57,239 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management22:20:57,240 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:999022:20:57,241 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4836ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

在另一个外壳中,获取容器的IP地址为:

~> boot2docker ipThe VM's Host only interface IP address is: 192.168.59.103

然后通过http://192.168.59.103访问WildFly。

同样,运行WildFly Ubuntu映像显示:

wildfly-ubuntu> docker run -i -t -p 80:8080 wildfly-ubuntu=========================================================================JBoss Bootstrap EnvironmentJBOSS_HOME: /opt/jboss/wildflyJAVA: /usr/lib/jvm/java-7-openjdk-amd64/bin/javaJAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true=========================================================================22:34:07,612 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final22:34:07,911 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final22:34:07,996 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting22:34:09,076 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)22:34:09,097 INFO [org.xnio] (MSC service thread 1-9) XNIO version 3.3.0.Final22:34:09,106 INFO [org.xnio.nio] (MSC service thread 1-9) XNIO NIO Implementation Version 3.3.0.Final22:34:09,136 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.22:34:09,170 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem22:34:09,180 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.22:34:09,191 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]22:34:09,207 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem22:34:09,212 INFO [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Final22:34:09,230 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension22:34:09,317 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017502: Undertow 1.1.0.Final starting22:34:09,317 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting22:34:09,323 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors22:34:09,413 INFO [org.jboss.as.connector.logging] (MSC service thread 1-15) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)22:34:09,617 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)22:34:09,658 INFO [org.jboss.as.naming] (MSC service thread 1-10) JBAS011802: Starting Naming Service22:34:09,674 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session 22:34:09,692 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-12) JBAS010417: Started Driver service with driver-name = h222:34:09,693 INFO [org.jboss.remoting] (MSC service thread 1-9) JBoss Remoting version 4.0.6.Final22:34:11,117 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content22:34:11,134 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017525: Started server default-server.22:34:11,206 INFO [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting22:34:11,377 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:808022:34:11,576 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments22:34:11,627 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source 22:34:11,847 INFO [org.mon.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final22:34:11,911 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management22:34:11,912 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:999022:34:11,912 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4762ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

您可以如下所示登录到主机VM:

boot2docker ssh

映像的不同层存储在/var/lib/docker目录中,如下所示:

docker-images> boot2docker ssh## .## ## ## ==## ## ## ##===/""""""""""""""""\___/ ===~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~\______ o__/\ \ __/\____\______/_ _ _____ _| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ ||_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|Boot2Docker version 1.3.2, build master : 495c19a - Mon Nov 24 20:40:58 UTC Docker version 1.3.2, build 39fa2fadocker@boot2docker:~$ cd /var/lib/docker/docker@boot2docker:/mnt/sda1/var/lib/docker$ ls -latotal 64drwxr-xr-x 10 rootroot4096 Nov 24 23:33 ./drwxr-xr-x 4 rootroot4096 Nov 24 19:15 ../drwxr-xr-x 5 rootroot4096 Nov 24 19:16 aufs/drwx------ 17 rootroot4096 Nov 24 23:33 containers/drwx------ 3 rootroot4096 Nov 24 19:16 execdriver/drwx------ 84 rootroot 12288 Nov 24 23:28 graph/drwx------ 2 rootroot4096 Nov 25 14:50 init/-rw-r--r-- 1 rootroot 11264 Nov 24 23:33 linkgraph.db-rw------- 1 rootroot 565 Nov 24 23:28 repositories-aufsdrwx------ 2 rootroot4096 Nov 24 23:28 tmp/drwx------ 2 rootroot4096 Nov 24 19:21 trust/drwx------ 2 rootroot4096 Nov 24 19:16 volumes/

Mac OSX上的VM映像存储在~/VirtualBox VMs/boot2docker-vm目录中。 如果不删除中间容器,此目录可以快速增长。 对于这些不同的映像,我机器上的boot2docker-vm.vmdk约为5GB。

您可以通过运行以下命令来重置它(警告:这将破坏您到目前为止下载并构建的所有图像):

boot2docker downboot2docker destroyboot2docker initboot2docker up

您可以想象,容器具有存储足迹。

后续博客中将出现更多Docker优点!

翻译自: //12/create-your-own-docker-image-tech-tip-57.html

docker 删除映像

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。