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?

More than 3 years have passed since last update.

WindowsでBashコンテナを動かすためのバッチファイル

0
Last updated at Posted at 2019-04-04

Bashを動かす環境をDockerコンテナで作って、Windows(Docker CE on Ubuntu on WSL2 or Docker Desktop)から簡単に利用できるようにするためのバッチファイル。

Dockerイメージのビルド(build_bash.bat)

@echo off

cd /d %~dp0

# Docker Desktop環境ではwslは不要
wsl docker build ^
  -t bash ^
  .

echo Press any key to finish.
pause > NUL

Dockerコンテナ起動(run_bash.bat)

@echo off

cd /d %~dp0

wsl docker stop bash > NUL 2>&1

wsl docker run ^
  -it ^
  --rm ^
  --name bash ^
  -v /c:/c ^
  bash

if %errorlevel% neq 0 pause

Dockerfile

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y \
      locales \
      gettext-base \
      vim \
      python3 \
      python3-pip \
      curl \
    && locale-gen ja_JP.UTF-8 \
    && echo "export LANG=ja_JP.UTF-8" >> ~/.bashrc

CMD ["bash"]
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?