kkamagi's story

IT, 정보보안, 포렌식, 일상 공유

Docker

docker nginx & python 3.9 설치

까마기 2020. 11. 5. 12:47
728x90
반응형

>docker pull nginx

>mkdir F:\nginx

* 해당 폴더 안에 디폴트 페이지 생성

ex)

#vi index.html

wow Hello Docker

출처: https://minimilab.tistory.com/8 [MINIMI LAB]

 

>docker run --name nginx_sec -v F:\nginx:/usr/share/nginx/html:ro -d -p 80:80 nginx

 

* 위 명령어 수행 시 ':' 콜론 문자 때문에 에러가 나므로 F:\ 경로로 들어가서 콜론을 사용하지 않도록 한 상태에서 연결할 디렉터리를 지정

F:\>docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                NAMES
566cc08b146b        nginx               "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp   nginx_sec

F:\>docker exec -it 56 bash
root@566cc08b146b:/#

 

apt update

apt upgrade

apt-get update

apt-get install software-properties-common vim net-tools gpg iputils-ping -y

apt-get update && apt-get install procps -y 

* procps : ps 명령어 설치

 

 

>docker commit nginx:latest

 

---------------------------------

 

* python 3.9 설치

# add-apt-repository ppa:deadsnakes/ppa

# apt update

# apt install wget software-properties-common

# apt install python3.9

4.) (NOT Recommended) To use Python 3.9 as the default python3, run commands:

 

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2

 

* ppa 관련 에러가 나타날 경우 해당 ppa 제거

sudo add-apt-repository --remove ppa:webupd8team/ppa

sudo apt update

stackoverflow.com/questions/62028180/ubuntu-19-04-error-404-not-found-ip-91-189-95-83-80-error-on-apt-update

 

Ubuntu 19.04 Error 404 Not Found [IP: 91.189.95.83 80] error on apt update

I had uninstalled open jdk and trying to install oracle jdk8 but getting following error oracle@ubuntu:~/Downloads$ sudo apt update Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease Hit:2...

stackoverflow.com

 

For Ubuntu 16.04 and Ubuntu 18.04, replace python3.8 in the code with system’s default python3 version..
And you can then switch between the two Python3 versions via command:

 

sudo update-alternatives --config python3

 

NOTE: Due to known bug, terminal won’t open if you changed python3 symlink. An workaround is recreate a symlink via command (Replace python 3.8 with your system default python3 version):sudo rm /usr/bin/python3; sudo ln -s python3.8 /usr/bin/python3Uninstall:

To uninstall the Python3.9 packages, run command:

sudo apt remove --autoremove python3.9 python3.9-minimal

 

ubuntuhandbook.org/index.php/2020/10/python-3-9-0-released-install-ppa-ubuntu/

 

Python 3.9.0 Released, How to Install via PPA in Ubuntu | UbuntuHandbook

Python programming language 3.9.0 was released with new features and optimizations. Here’s how to install it in Ubuntu 16.04, Ubuntu 18.04, and Ubuntu 20.04 via PPA. Python 3.9.0 is the first version default to the 64-bit installer on Windows. Windows 7

ubuntuhandbook.org

Installing Python 3.9 Using Source Code

You also have one more option option to install Python 3.9 using source code. We don’t recommend to install Python 3.9 packages from source code. But in some cases you may need to install Python from source code.

So follow the below instructions to install Python 3.9 using source code on Ubuntu 20.04 Linux system.

  1. First of all, install essential packages for compiling source code. Open a terminal and execute following commands:
  2.  
  3. sudo apt install build-essential checkinstall
  4. sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
  5. Now, download the Python 3.9 source code from official download site. Switch to a relevant directory and use wget to download source file.
  6. cd /opt
  7. sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
  8. Next, extract the downloaded archive file and prepare the source for the installation.
  9. tar xzf Python-3.9.0.tgz
  10. cd Python-3.9.0
  11. sudo ./configure --enable-optimizations
  12. Python source is ready to install. Execute make altinstall command to install Python 3.9 on your system.
  13. sudo make altinstall

    make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

  14. The Python 3.9 has been installed on Ubuntu 18.04 system. Verify the installed version:
  15. python3.9 -V
  16. Python 3.9.0
  17. Remove the downloaded archive to free space
  18. sudo rm -f /opt/Python-3.9.0.tgz

Conclusion

In this tutorial, you have learned to install Python 3.9 on Ubuntu 20.04 using Apt and source code. You can try Python examples via command line.

 

 

* pip 설치 (파이썬 설치 후)

# apt-get install python-pip

 

* docker-compose 설치

# pip install docker-compose

반응형