0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[自分用メモ]docker-compose.ymlを使用したコンテナ構築

Last updated at Posted at 2025-02-11
  1. rootユーザに移行

  2. docker-composeのインストール

    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    
  3. 実行権限を付与

    sudo chmod +x /usr/local/bin/docker-compose
    
  4. docker-compose.ymlファイルを作成

    vim docker-compose.yml
    

    以下は、docker-compose.yml の例

    docker-compose.yml
     services:
       ansible-container:
         image: ansible-container-image
         container_name: ansible-container
         network_mode: host   # ホストのネットワークを使う
         tty: true            # コンテナ内でインタラクティブに作業できるようにする
         build: ./Dockerfile
         command: sleep infinity
    
  5. MakeFileの作成

    vim Makefile
    

    内容は以下

    # Rocky Linux 9のベースイメージを取得
    pull-image:
            docker pull rockylinux:9
    
    # docker-compose.ymlを実行
    up: pull-image
            docker-compose up
    
  6. makeを実行

    make up
    
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?