1
0

More than 1 year has passed since last update.

Conoha VPS (Ubuntu)にDockerでUbuntu20.04+Python3.8環境を構築する

Last updated at Posted at 2021-11-27

Conoha(Ubuntu18.04)にDockerでUbuntu20.04+Python3.8環境を構築しようと思って調べた内容をまとめる。(コピペで動きます)

imageをpull

docker image pull ubuntu:20.04

imageを確認

docker images

Docker imageを解凍

(ubuntu2004の部分は自由に名前を変更してください)

docker container run -it -d --name ubuntu2004 ubuntu:20.04

image内に入る

docker exec -it ubuntu2004 /bin/bash

gitをインストールする

sudo apt-get install git

※bash: sudo:command not foundと出たときは「apt update&apt install sudo」する。

git clone

git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

vimをインストールする

sudo apt-get install vim

profile をvimで編集

vi ~/.profile

profile に以下を追記

export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"

再読み込みする

source ~/.profile

libffi-devをインストール

sudo apt install libffi-dev

curlをインストール

apt install curl

aria2cをインストール

apt install aria2c

wgetをインストール

apt install wget

いろいろインストール(途中地域選択あり)

apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

python3.8.10 をインストール

pyenv install 3.8.10 
pyenv global 3.8.10

バージョン確認

python3 --version
>Python 3.8.10

(おまけ)ついでにpipをインストール

apt install python3-pip

Dockerfileにまとめれたら、また記事を書こうかな。

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