2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Dockerfile版】DockerでWindowsを操作できるAnsibleコンテナを構築する

2
Last updated at Posted at 2019-02-10

[DockerでWindowsを操作できるAnsibleコンテナを構築する]
(https://qiita.com/myalpine/items/ea18b3b22c14c60efc3c)をDockerfileで書いてみました。

コンテナ完成までの流れ

  1. Dockerfile(イメージ作成の定義ファイル)を作成
  2. Dockerイメージを作成(docker buildコマンド)
  3. コンテナを作成して起動(docker runコマンド)

1. Dockerfile(イメージ作成の定義ファイル)を作成

Docker for Windowsで作業を進めていきます。
ディレクトリ: C:\Ansible
Dockerfileは以下の通り。

Dockerfile
# ベースとなるイメージ
FROM centos:centos7

# 作成したユーザの情報
MAINTAINER myalpine

# SSHをインストール
RUN yum install -y openssh-server openssh-clients sshpass

# pipをインストール
RUN curl https://bootstrap.pypa.io/get-pip.py | python

# pywinrmをインストール
RUN pip install pywinrm

# Ansibleをインストール
RUN yum install -y epel-release && yum install -y ansible

2. Dockerイメージを作成(docker buildコマンド)

Dockerfileがある「C:\Ansible」上でビルドします。

C:\Ansible> docker build -t ansible .

Dockerイメージができたことを確認。

C:\Ansible> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ansible             latest              8deb4dc504a0        6 seconds ago       514MB
centos              centos7             1e1148e4cc2c        2 months ago        202MB

3. コンテナを作成して起動(docker runコマンド)

C:\Ansible> docker run -it -d --name ansible ansible:latest
5611fc63e9ffc656eb40e02074b5c6d4f622b2dada64bf88e958dc353d13e38f
C:\Ansible> docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
5611fc63e9ff        ansible:latest      "/bin/bash"         2 minutes ago       Up 2 minutes                            ansible

Windowsを操作できるAnsibleコンテナが完成しました!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?