LoginSignup
5
2

More than 5 years have passed since last update.

Ubuntuを起動するためだけにdocker-composeを使う(日本語化も)

Posted at

Mac上でLinuxの練習をするためにubuntuの環境を構築したい。
ただそれだけのためにdocker-composeを使ってみました。

dockerコマンドよりdocker-composeの操作に比較的慣れているからというただそれだけの理由です。

フォルダ構成

任意のフォルダを作成して、その中に以下を作っていくよー

.
├── docker-compose.yml
└── ubuntu
    └── Dockerfile

各ファイル

ubuntu/Dockerfile

FROM ubuntu:16.04

# 日本語化
RUN apt-get update \
  && apt-get install -y locales \ 
  && locale-gen ja_JP.UTF-8 \
  && echo "export LANG=ja_JP.UTF-8" >> ~/.bashrc

docker-compose.yml

version: '3'
services:
  ubuntu:
    build: ubuntu
    container_name: "ubuntu"
    tty: true

起動

ファイルの用意ができたらビルドします
(初回は時間がかかるよ)

$ docker-compose build

dockerを起動します

$ docker-compose up -d
Recreating ubuntu ... done

起動を確認します

$ docker-compose ps
 Name     Command    State   Ports
----------------------------------
ubuntu   /bin/bash   Up 

ubuntuにログインします

$ docker exec -it ubuntu bash
root@39f188f02ef7:/#

入れました!

以上です^^

5
2
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
5
2