Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2722

【小ネタ】DockerでubuntuにPythonインストールすべくapt searchするも見つからない

$
0
0

前提

公式イメージのnginxをpullしておく。

Pythonインストールしたく

コンテナに入ってpython検索するも、、

❯ docker container run -it nginx:latest bash
root@487042b15fe4:/# apt search python
Sorting... Done
Full Text Search... Done
libhogweed4/now 3.4.1-1 amd64 [installed,local]
  low level cryptographic library (public-key cryptos)

libnettle6/now 3.4.1-1 amd64 [installed,local]
  low level cryptographic library (symmetric and one-way cryptos)

これしか出てこなく、あれ?ってなる。

解決策

aptをupdateする。

root@260aef3fab91:/# apt update
Get:1 http://cdn-fastly.deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7899 kB]
Get:5 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [108 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian buster-updates/main amd64 Packages [5792 B]
Fetched 8222 kB in 3s (2716 kB/s)                    
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

解決→めっさ出てきたw

root@260aef3fab91:/# apt search python3
Sorting... Done
Full Text Search... Done
2to3/stable 3.7.3-1 all
  2to3 binary using python3

astro-python3/stable 2.0 all
  Python 3 packages for astronomy

bpython3/stable 0.17.1-1 all
  fancy interface to the Python 3 interpreter

cantor-backend-python3/stable 4:18.12.0-2 amd64
  Python3 backend for Cantor

cupp3/stable 0.0+20160624.git07f9b8-1 all
  generate dictionaries for attacks from personal data version for python3

flatlatex/stable 0.8-1 all
  Python3 LaTeX math converter to unicode text - binaries

freecad-python3/stable 0.18~pre1+dfsg1-5 amd64
  Extensible Open Source CAx program - Python 3 binaries

games-python3-dev/stable 3 all
  development of games in Python 3

gcc-python3-dbg-plugin/stable 0.17-2 amd64
  plugin for GCC to invoke Python scripts from inside the compiler

gcc-python3-plugin/stable 0.17-2 amd64
  plugin for GCC to invoke Python scripts from inside the compiler

gstreamer1.0-python3-dbg-plugin-loader/stable 1.14.4-1+b1 amd64
  GStreamer Loader for Python Plugin (Python 3, debug extensions)

gstreamer1.0-python3-plugin-loader/stable 1.14.4-1+b1 amd64
  GStreamer Loader for Python Plugin (Python 3)

hexchat-python3/stable 2.14.2-4 amd64
  Python 3 plugin for HexChat

humanfriendly/stable 4.18-1 all
  Helper command for the humanfriendly Python3 library

idle-python3.7/stable 3.7.3-2 all
  IDE for Python (v3.7) using Tkinter

ipython3/stable 5.8.0-1 all
  Enhanced interactive Python 3 shell

ipython3-qtconsole/stable 4.3.1-1 all
  transitional dummy package for python3-qtconsole

isympy3/stable 1.3-2 all
  Python3 shell for SymPy

kamailio-python3-modules/stable 5.2.1-1 amd64
  The app_python3 module for the Kamailio SIP server

libcasa-python3/stable 3.0.0-4 amd64
  CASA legacy Python 2 bindings

libcasa-python3-3/stable 3.0.0-4 amd64
  CASA Python bindings

libfreecad-python3-0.18/stable 0.18~pre1+dfsg1-5 amd64
  Extensible Open Source CAx program - Python 3 library files

libpython3-all-dbg/stable 3.7.3-1 amd64
  package depending on all supported Python 3 debugging packages

libpython3-all-dev/stable 3.7.3-1 amd64
  package depending on all supported Python 3 development packages

libpython3-dbg/stable 3.7.3-1 amd64
  debug build of the Python 3 Interpreter (version 3.7)

libpython3-dev/stable 3.7.3-1 amd64
  header files and a static library for Python (default)

libpython3-stdlib/stable 3.7.3-1 amd64
  interactive high-level object-oriented language (default python3 version)

libpython3.7/stable 3.7.3-2 amd64
  Shared Python runtime library (version 3.7)

libpython3.7-dbg/stable 3.7.3-2 amd64
  Debug Build of the Python Interpreter (version 3.7)

libpython3.7-dev/stable 3.7.3-2 amd64
  Header files and a static library for Python (v3.7)

libpython3.7-minimal/stable 3.7.3-2 amd64
  Minimal subset of the Python language (version 3.7)

libpython3.7-stdlib/stable 3.7.3-2 amd64
  Interactive high-level object-oriented language (standard library, version 3.7)

libpython3.7-testsuite/stable 3.7.3-2 all
  Testsuite for the Python standard library (v3.7)

libshiboken-py3-1.2v5/stable 1.2.2-5.1+b1 amd64
  CPython3 bindings generator for C++ libraries - shared library

libshiboken2-py3-5.11/stable 5.11.2-3 amd64
  CPython bindings generator for C++ libraries (Python3 shared library)

postgresql-11-python3-multicorn/stable 1.3.4-4 amd64
  multicorn extension for Postgres 11 to write FDWs with python3

postgresql-plpython3-11/stable,stable 11.5-1+deb10u1 amd64
  PL/Python 3 procedural language for PostgreSQL 11

py3status/stable 3.14-2 all
  extensible i3status wrapper written in Python (Python3 package)

pylama/stable 7.4.3-2 all
  code audit tool for Python in Python3

python-bx-tools/stable 0.8.2-1 all
  command line interface to python3-bx

python-cerberus-doc/stable 1.2-2 all
  Documentation for python3-cerberus

python-django-celery-beat-doc/stable 1.1.1-1 all
  Database-backed Periodic Tasks (Python3 version)

python-django-python3-ldap/stable 0.11.2-1 all
  Django LDAP user authentication backend (Python2 version)

python-mando-doc/stable 0.6.4-4 all
  command line argument parser for python3 (common documentation)

python-odf-doc/stable 1.4.0-1 all
  documentation and examples for python-odf and python3-odf

python-openslide-examples/stable 1.1.1-4 all
  Python examples for python-openslide and python3-openslide

python-requests-toolbelt-doc/stable 0.8.0-1 all
  Utility belt for python3-requests (documentation)

python-x2gobroker-doc/stable 0.0.4.1-1 all
  X2Go Session Broker (Python3 module documentation)

python3/stable 3.7.3-1 amd64
  interactive high-level object-oriented language (default python3 version)

python3-aalib/stable 0.3.2-3 all
  Python 3 interface to AAlib, an ASCII art library

python3-acme/stable 0.31.0-2 all
  ACME protocol library for Python 3

...(まだまだまだ依存関係続くので以下省略)

インストール。

root@260aef3fab91:/# apt install python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  bzip2 file libmagic-mgc libmagic1 libmpdec2 libpython3-stdlib libpython3.7-minimal libpython3.7-stdlib libsqlite3-0 mime-support python3-minimal python3.7 python3.7-minimal xz-utils
Suggested packages:
  bzip2-doc python3-doc python3-tk python3-venv python3.7-venv python3.7-doc binutils binfmt-support
The following NEW packages will be installed:
  bzip2 file libmagic-mgc libmagic1 libmpdec2 libpython3-stdlib libpython3.7-minimal libpython3.7-stdlib libsqlite3-0 mime-support python3 python3-minimal python3.7 python3.7-minimal xz-utils
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 5927 kB of archives.
After this operation, 31.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://security-cdn.debian.org/debian-security buster/updates/main amd64 libmagic-mgc amd64 1:5.35-4+deb10u1 [242 kB]
Get:2 http://security-cdn.debian.org/debian-security buster/updates/main amd64 libmagic1 amd64 1:5.35-4+deb10u1 [117 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libpython3.7-minimal amd64 3.7.3-2 [588 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian buster/main amd64 python3.7-minimal amd64 3.7.3-2 [1736 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 python3-minimal amd64 3.7.3-1 [36.6 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian buster/main amd64 mime-support all 3.62 [37.2 kB]
Get:7 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libmpdec2 amd64 2.4.2-2 [87.2 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libsqlite3-0 amd64 3.27.2-3 [641 kB]
Get:9 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libpython3.7-stdlib amd64 3.7.3-2 [1732 kB]
Get:10 http://security-cdn.debian.org/debian-security buster/updates/main amd64 file amd64 1:5.35-4+deb10u1 [66.4 kB]
Get:11 http://cdn-fastly.deb.debian.org/debian buster/main amd64 python3.7 amd64 3.7.3-2 [330 kB]
Get:12 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libpython3-stdlib amd64 3.7.3-1 [20.0 kB]
Get:13 http://cdn-fastly.deb.debian.org/debian buster/main amd64 python3 amd64 3.7.3-1 [61.5 kB]
Get:14 http://cdn-fastly.deb.debian.org/debian buster/main amd64 bzip2 amd64 1.0.6-9.2~deb10u1 [48.4 kB]                                                                                                                                                        
Get:15 http://cdn-fastly.deb.debian.org/debian buster/main amd64 xz-utils amd64 5.2.4-1 [183 kB]                                                                                                                                                                
Fetched 5927 kB in 11s (539 kB/s)                                                                                                                                                                                                                               
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython3.7-minimal:amd64.
(Reading database ... 7203 files and directories currently installed.)
Preparing to unpack .../libpython3.7-minimal_3.7.3-2_amd64.deb ...
Unpacking libpython3.7-minimal:amd64 (3.7.3-2) ...
Selecting previously unselected package python3.7-minimal.
Preparing to unpack .../python3.7-minimal_3.7.3-2_amd64.deb ...
Unpacking python3.7-minimal (3.7.3-2) ...
Setting up libpython3.7-minimal:amd64 (3.7.3-2) ...
Setting up python3.7-minimal (3.7.3-2) ...
Selecting previously unselected package python3-minimal.
(Reading database ... 7444 files and directories currently installed.)
Preparing to unpack .../0-python3-minimal_3.7.3-1_amd64.deb ...
Unpacking python3-minimal (3.7.3-1) ...
Selecting previously unselected package mime-support.
Preparing to unpack .../1-mime-support_3.62_all.deb ...
Unpacking mime-support (3.62) ...
Selecting previously unselected package libmpdec2:amd64.
Preparing to unpack .../2-libmpdec2_2.4.2-2_amd64.deb ...
Unpacking libmpdec2:amd64 (2.4.2-2) ...
Selecting previously unselected package libsqlite3-0:amd64.
Preparing to unpack .../3-libsqlite3-0_3.27.2-3_amd64.deb ...
Unpacking libsqlite3-0:amd64 (3.27.2-3) ...
Selecting previously unselected package libpython3.7-stdlib:amd64.
Preparing to unpack .../4-libpython3.7-stdlib_3.7.3-2_amd64.deb ...
Unpacking libpython3.7-stdlib:amd64 (3.7.3-2) ...
Selecting previously unselected package python3.7.
Preparing to unpack .../5-python3.7_3.7.3-2_amd64.deb ...
Unpacking python3.7 (3.7.3-2) ...
Selecting previously unselected package libpython3-stdlib:amd64.
Preparing to unpack .../6-libpython3-stdlib_3.7.3-1_amd64.deb ...
Unpacking libpython3-stdlib:amd64 (3.7.3-1) ...
Setting up python3-minimal (3.7.3-1) ...
Selecting previously unselected package python3.
(Reading database ... 7889 files and directories currently installed.)
Preparing to unpack .../0-python3_3.7.3-1_amd64.deb ...
Unpacking python3 (3.7.3-1) ...
Selecting previously unselected package bzip2.
Preparing to unpack .../1-bzip2_1.0.6-9.2~deb10u1_amd64.deb ...
Unpacking bzip2 (1.0.6-9.2~deb10u1) ...
Selecting previously unselected package libmagic-mgc.
Preparing to unpack .../2-libmagic-mgc_1%3a5.35-4+deb10u1_amd64.deb ...
Unpacking libmagic-mgc (1:5.35-4+deb10u1) ...
Selecting previously unselected package libmagic1:amd64.
Preparing to unpack .../3-libmagic1_1%3a5.35-4+deb10u1_amd64.deb ...
Unpacking libmagic1:amd64 (1:5.35-4+deb10u1) ...
Selecting previously unselected package file.
Preparing to unpack .../4-file_1%3a5.35-4+deb10u1_amd64.deb ...
Unpacking file (1:5.35-4+deb10u1) ...
Selecting previously unselected package xz-utils.
Preparing to unpack .../5-xz-utils_5.2.4-1_amd64.deb ...
Unpacking xz-utils (5.2.4-1) ...
Setting up mime-support (3.62) ...
Setting up libmagic-mgc (1:5.35-4+deb10u1) ...
Setting up libsqlite3-0:amd64 (3.27.2-3) ...
Setting up libmagic1:amd64 (1:5.35-4+deb10u1) ...
Setting up file (1:5.35-4+deb10u1) ...
Setting up bzip2 (1.0.6-9.2~deb10u1) ...
Setting up xz-utils (5.2.4-1) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma)in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/lzma.1.gz because associated file /usr/share/man/man1/xz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/unlzma.1.gz because associated file /usr/share/man/man1/unxz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcat.1.gz because associated file /usr/share/man/man1/xzcat.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzmore.1.gz because associated file /usr/share/man/man1/xzmore.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzless.1.gz because associated file /usr/share/man/man1/xzless.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzdiff.1.gz because associated file /usr/share/man/man1/xzdiff.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcmp.1.gz because associated file /usr/share/man/man1/xzcmp.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzgrep.1.gz because associated file /usr/share/man/man1/xzgrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzegrep.1.gz because associated file /usr/share/man/man1/xzegrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzfgrep.1.gz because associated file /usr/share/man/man1/xzfgrep.1.gz (of link group lzma) doesn't exist
Setting up libmpdec2:amd64 (2.4.2-2) ...
Setting up libpython3.7-stdlib:amd64 (3.7.3-2) ...
Setting up libpython3-stdlib:amd64 (3.7.3-1) ...
Setting up python3.7 (3.7.3-2) ...
Setting up python3 (3.7.3-1) ...
running python rtupdate hooks for python3.7...
running python post-rtupdate hooks for python3.7...
Processing triggers for libc-bin (2.28-10) ...

できました。

root@260aef3fab91:/# python3 --version
Python 3.7.3

というわけでDockerfileはこんな感じ

❯ vim Dockerfile-nginx 

FROM nginx:latest

COPY ./index.html /usr/share/nginx/html/
COPY ./server.conf /etc/nginx/conf.d/

RUN apt update && \
    apt install -y python3 && \
    python3 --version

終わり

ubuntu初めて触りました。弱々ですみません。
ご覧いただきありがとうございました。


Viewing all articles
Browse latest Browse all 2722

Trending Articles