CentOSのインストール7ドッカー-CEのコミュニティ版
インストールのドッキングウィンドウの依存関係
yum install -y yum-utils device-mapper-persistent-data lvm2
ドッカー-CEソースソフトウェアを追加
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
閉鎖縁バージョンとドッカー-CEのテスト版
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test
ヤムアップデート元
yum makecache fast
インストールドッカー-CE(最初のインストール)
yum install docker-ce -y
インストールが成功したかどうかを確認するには
docker version
Client:
Version: 18.06.1-ce-rc1
API version: 1.38
Go version: go1.10.3
Git commit: 0928140
Built: Wed Aug 8 01:35:58 2018
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ビューインストールされたバージョンを供給することができる(第2のインストール)
yum list docker-ce --showduplicates|sort -r
ドッカー-CEの指定したバージョンをインストールします。
yum install docker-ce-17.09.0.ce -y
使用ドッカードッカーインストールスクリプト(第3の方法)
ドッカーインストールスクリプトをダウンロード
curl -fsSL get.docker.com -o get-docker.sh
ドッカーミラーaliyunスクリプトを実行します
sh get-docker.sh --mirror Aliyun
国内ドッカーミラーミラーソースの倉庫を交換してください
登録Daocloudアカウント、およびログDaocloud
https://www.daocloud.io/mirror#accelerator-doc
Daocloud国内のミラーリングコマンドを交換します
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://e674da1e.m.daocloud.io
ドッカーが発効国内源泉を再起動します
systemctl restart docker
ドッカーランダムなスタートを追加
systemctl enable docker
ドッカーミラー基本操作
引っ張っgithubのミラーからの
コマンド形式:
docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]
倉庫ドッカーミラーアドレス:アドレスは一般的には<ドメイン名/ IP> [:ポート番号]。デフォルトのアドレスは、ドッカーハブです。
倉庫名:二段名、つまり<ユーザー名> / <ソフトウェア名>。ドッカーハブのために、あなたは、公式の画像であるライブラリーのデフォルトのユーザー名を与えない場合。
例:
docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
c64513b74145: Pull complete
01b8b12bad90: Pull complete
c5d85cf7a05f: Pull complete
b6b268720157: Pull complete
e12192999ff1: Pull complete
Digest: sha256:8c3cced1211d1a566088c0af049cc8cd6f33f5b275e62e6285ca6a13e66a98f0
Status: Downloaded newer image for ubuntu:latest
リストローカルダウンロードされたイメージ
docker image
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 735f80812f90 2 weeks ago 83.5MB
hello-world latest 2cb0d9787c4d 4 weeks ago 1.85kB
削除ローカルミラー
docker image rm -f 2cb0d9787c4d
鏡ID、画像の名前によると、概要がミラーを削除します
使用Dockerfileは、独自のイメージを構築します
空白のディレクトリを作成し、ディレクトリを入力します。
mkdir first
cd first/
このディレクトリにカスタマイズされたイメージファイルをアップロードする必要があります
[root@MiWiFi-R3-srv ~]# cd first/
[root@MiWiFi-R3-srv first]# ll
总用量 12
-rw-r--r--. 1 root root 604 8月 11 15:50 Dockerfile
-rw-r--r--. 1 root root 230 8月 11 14:57 index.js
-rw-r--r--. 1 root root 228 8月 11 14:58 package.json
[root@MiWiFi-R3-srv first]#
編集Dockerfileファイル
# 基础镜像来自于 hub.docker.com
FROM centos
#镜像维护信息 https://xiaopangsoftware.taobao.com
MAINTAINER xiaopangruanjianxuetang
#指定工作目录
WORKDIR /app
#将项目相关文件拷贝到app下,如果目录不存在会自动创建
COPY index.js /app
COPY package.json /app
# 安装命令来自于 nodejs 官网 https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora
RUN curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - && yum -y install nodejs && npm install
#暴露端口
EXPOSE 8080
#容器启动命令
CMD ["node", "/app/index.js"]
ミラーの構築
docker build -t xiaopang/centos-nodejs-1 .
お名前/画像名を-t
成功したショーの結果を構築するの後半
...
npm notice created a lockfile as package-lock.json. You should commit this file.
added 50 packages in 9.583s
Removing intermediate container 8dc630bdf3fd
---> f0beb800684a
Step 7/8 : EXPOSE 8080
---> Running in f1e679738194
Removing intermediate container f1e679738194
---> 3c0c770cd1c2
Step 8/8 : CMD ["node", "/app/index.js"]
---> Running in 9377ccc41407
Removing intermediate container 9377ccc41407
---> cea31fd11519
Successfully built cea31fd11519
Successfully tagged xiaopang/centos-nodejs-1:latest
ビューのビルドに成功した画像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaopang/centos-nodejs-1 latest cea31fd11519 7 minutes ago 343MB
centos latest 5182e96772bf 4 days ago 200MB
ubuntu latest 735f80812f90 2 weeks ago 83.5MB
新しいビルドイメージを実行します
docker run -p 8080:8080 -d xiaopang/centos-nodejs-1
画像が成功を生成するかどうかを確認するために、アクセス8080、
[root@localhost first]# curl http://127.0.0.1:8080
Hello World
あなたの成功のミラーリングおめでとうございます
あなたは問題が発生する可能性があります
ドッキングウィンドウのビルド报错[警告]のIPv4転送が無効になっています。ネットワークが機能しません。
- 編集00-あるsystem.conf
vim /usr/lib/sysctl.d/00-system.conf
- 以下を追加
net.ipv4.ip_forward=1
- 再起動のカードサービス
systemctl restart network