1
2

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.

[自分メモ]Dockerコンテナの立ち上げメモ

Last updated at Posted at 2020-01-04

イマドキDocker使うなんて当たり前だけど、あまりまともに触ったことなかったので、最初の使い方をまとめる。

コマンドで実行する

イメージを取得する

  • Docker Hubで目的のイメージのページを探す
  • pull する

$ docker pull ubuntu:latest

立ち上げる

  • 取得したイメージをrunする

コンテナの立ち上げ。


$ docker run -it -d --name ubuntulatest ubuntu:latest

立ち上げたイメージ上で操作する


$ docker exec -it ubuntulatest /bin/bash

コンテナの停止


$ docker stop ubuntulatest

コンテナの削除


$ docker rm ubuntulatest

Dockerfileを使う

チーム開発などの場合、複数人間で環境を共通化したい。
その場合は、Dockerfileを作成し、立ち上げる。
以下は、DockerHubのRubyイメージを参考にする。

ドキュメント
http://docs.docker.jp/engine/reference/builder.html

Dockerfileを作成


# ベースとなるイメージ
FROM ruby:2.5 

# コマンドを走らせる
RUN  bundle config --global frozen 1 
...

ビルド


$ docker build -t my-ruby-app .

立ち上げ

$ docker run -it --name my-running-script my-ruby-app

参考資料

DockerでUbuntu 16.04 LTSのイメージを利用してみよう
https://weblabo.oscasierra.net/docker-ubuntu1604/

1
2
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?