Code Monkey home page Code Monkey logo

mini-docker-handson's Introduction

コンテナ型仮想環境の実装

コンテナ型仮想化を実装することで仮想化に関する理解を深める。 プロセスを隔離しその中で簡単なコマンドを実行するところまでを作成した。

セットアップ

vagrantのインストール

https://www.vagrantup.com/downloads

VMの作成と起動

vagrant up
vagrant ssh

VMの動作確認

以下の動作確認はVM内で実施した。
vagrant sshでVirtualBox上の仮想環境に移動できる。

OSの確認

cat /etc/os-release

# --->
# NAME="Ubuntu"
# VERSION="20.10 (Groovy Gorilla)"
# ID=ubuntu
# ID_LIKE=debian
# PRETTY_NAME="Ubuntu 20.10"
# VERSION_ID="20.10"

コマンドの確認

コマンドはmini-dockerに実装した。
システムコールを用いるため、特権ユーザーで実行する。

sudo su -
cd /vagrant
  • イメージの取得
./mini-docker pull <取得したいDockerイメージ名>

# ---> 
# pulling <registry名>/<image名>:<tag名> ...
# Fetching manifest for <image名>:<tag名>
# Fetching layer: sha256:hogehoge
# Fetching layer: sha256:hugahuga
# 👌 Docker image <image名>:<tag名> has been stored in /var/opt/app/images/library_<image名>_<tag名>
  • 取得したイメージの一覧取得
./mini-docker images
# ---> 
# fetching images
# +-------------------+---------+---------+---------------+
# | name              | version | size    | path          |
# +-------------------+---------+---------+---------------+
# | library/<image>   | <tag>   | <size>  | <path>        |
# +-------------------+---------+---------+---------------+
  • イメージの実行
./mini-docker run <image名> <command>
# ---> 
# parent_pid: <親プロセスのPID>
# child_pid:  <小プロセスのPID>
# <何かしらの処理>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.