How to install python3 with docker centos

Introduction

This article uses Amazon Linux 2 on AWS to do the following:

  1. Install docker
  2. Start centos which is docker image
  3. Install python3 in the container started in 2.

1. Install docker

First, update yum as follows.

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo yum update -y

Then install docker.

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo amazon-linux-extras install docker -y

After the installation is complete, start the docker daemon.

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo service docker start

Add ec2-user to the docker group. This is not required, but you can now use the `docker``` command without `sudo```.

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo usermod -a -G docker ec2-user

After executing the above command, close the terminal once. Then reconnect.

2. Start centos

First, start the container with the `run``` command. If the image has not been pulled, you can pull it before launching. The option `-it``` allows you to enter inside the launched container. (... is written by omitting the displayed message)

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ docker run -it centos
・
・
・
[root@xxx /]#

3. Install python3 in the container

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ yum install python3 -y

By entering the python3 command as shown below, you can enter interactive mode and know that it has been installed.

[root@xxx /]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

After installation, you can use the pip3 command to install the required packages. I'm installing version 1 of aws-cli with the following command:

[root@xxx /]# pip3 install awscli

Reference article

--AWS official website https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/docker-basics.html --Install pip and awscli on CentOS7 https://rriifftt.hatenablog.com/entry/2015/10/28/142043

Recommended Posts

How to install python3 with docker centos
How to install Python
How to install Python [Windows]
How to install python using anaconda
How to install python-pip with ubuntu20.04LTS
How to install PyPy on CentOS
How to get started with Python
How to install TensorFlow on CentOS 7
Unable to install Python with pyenv
How to use FTP with Python
How to calculate date with python
How to install mysql-connector with pip3
How to install Maven on CentOS
How to install Anaconda with pyenv
CentOS8 --Install --Python3
How to install NPI + send a message to line with python
How to install and use pandas_datareader [Python]
python3 How to install an external module
[Kivy] How to install Kivy on Windows [Python]
How to install DLIB with 2020 / CUDA enabled
Connect to MySQL with Python within Docker
How to work with BigQuery in Python
How to display python Japanese with lolipop
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
[Python] How to deal with module errors
How to install zsh (with .zshrc customization)
How to install pip
How to install archlinux
Install Python3.4 on CentOS 6.6
How to install BayesOpt
Install Voluptuous with Python 2.5
Use python with docker
Introducing Python 2.7 to CentOS 6.6
Install python with pyenv
How to install Nbextensions
How to upload with Heroku, Flask, Python, Git (4)
How to enjoy programming with Minecraft (Ruby, Python)
[REAPER] How to play with Reascript in Python
How to do multi-core parallel processing with python
[2020 version] How to install Python3 on AWS EC2
How to delete log with Docker, not to collect log
How to crop an image with Python + OpenCV
How to install Python for pharmaceutical company researchers
How to install OpenGM on OSX with macports
How to measure execution time with Python Part 1
How to use tkinter with python in pyenv
[Python] How to compare datetime with timezone added
[CentOS8] How to output Python standard output to systemd log
How to measure execution time with Python Part 2
Connect to BigQuery with Python
How to convert / restore a string with [] in python
python3: How to use bottle (2)
Install Python environment with Anaconda
How to scrape image data from flickr with python
How to do hash calculation with salt in Python
[Introduction to Python] How to iterate with the range function?
Tabpy 1.0 (2020-01 version) How to install
Connect to Wikipedia with Python
How to update Python Tkinter to 8.6
Post to slack with Python 3