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.

CentOSにPython3.8をインストール(docker利用)

Last updated at Posted at 2021-08-14

まあ、実際にはdockerfileやdocker-composeでまとめるのだが、
勉強がてら一度サクッとやってみるのはよさそう。
手順を間違えるとprint('テスト')するだけでエラーが出るので注意。(エラー時はGCCのバージョンに注目)

CentOS 7

コンテナ起動

docker run -it -d --name centos7 centos:centos7

コンテナに入る

docker exec -it centos7 /bin/bash

Python3.8をインストール

yum update yum -y
yum install -y centos-release-scl
yum install -y rh-python38 which
scl enable rh-python38 bash

Pythonの動作確認

[root@2c1d51bcffb9 /]# python3
Python 3.8.6 (default, Oct 27 2020, 09:13:12)
[GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('テスト')
テスト
>>> exit()

コンテナを停止して削除

docker stop centos7
docker rm centos7

CentOS 8

コンテナ起動

docker run -it -d --name centos8 centos:centos8

コンテナに入る

docker exec -it centos8 /bin/bash

Python3.8インストール

yum update yum -y
yum install python38 -y

Pythonの動作確認

[root@166a5a5ffebc /]# python3
Python 3.8.6 (default, Jan 29 2021, 17:38:16)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('テスト')
テスト
>>> exit()

コンテナを停止して削除

docker stop centos8
docker rm centos8
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?