컨테이너로 설치된 ubuntu 안에서 package 설치안될 때
반응형

아래와 같이 ubuntu 컨테이너를 생성했다.

# 아래와 같이 컨테이너 생성 후 실행
$ docker run -d -it --name airflow_test -p 8080:8080 ubuntu:20.04
Unable to find image 'ubuntu:20.04' locally
20.04: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:20.04
66053458a72903e6c59f29a66767a377fa2f9e81fa09c3ec6043c42b58b7a5bf

# 생성 결과 확인
$ docker ps -a
CONTAINER ID   IMAGE          COMMAND   CREATED              STATUS              PORTS                                       NAMES
66053458a729   ubuntu:20.04   "bash"    About a minute ago   Up About a minute   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   airflow_test

# 이미지도 다운로드됨
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       20.04     ba6acccedd29   10 days ago   72.8MB

 

컨테이너로 내부로 진입하여 추가 패키지 설치를 시도했다.

# 컨테이너 내부로 진입
$ docker exec -it airflow_test /bin/bash

# 컨테이너 생성 이미지는 최소 설치이므로 python3를 실행했으나 설치되어 있지 않다.
root@66053458a729:/# python3
bash: python3: command not found

# 설치를 시도했으나 패키지를 찾을 수 없다.
root@66053458a729:/# apt install python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3
root@66053458a729:/#

원인은 컨테이너 내부의 패키지 리스트가 업데이트되지 않아서이다.

# 패키지 목록 업데이트
root@66053458a729:/# apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [801 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
== 줄임 ==
Get:18 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [6310 B]                                                                                                                                                                                     
Fetched 19.5 MB in 15s (1285 kB/s)                                                                                                                                                                                                                                           
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

# 설치
root@66053458a729:/# apt install python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  file libexpat1 libmagic-mgc libmagic1 libmpdec2 libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib libreadline8 libsqlite3-0 libssl1.1 mime-support python3-minimal python3.8 python3.8-minimal readline-common xz-utils
Suggested packages:
  python3-doc python3-tk python3-venv python3.8-venv python3.8-doc binutils binfmt-support readline-doc
The following NEW packages will be installed:
  file libexpat1 libmagic-mgc libmagic1 libmpdec2 libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib libreadline8 libsqlite3-0 libssl1.1 mime-support python3 python3-minimal python3.8 python3.8-minimal readline-common xz-utils
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 7395 kB of archives.
After this operation, 32.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl1.1 amd64 1.1.1f-1ubuntu2.8 [1320 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.10-0ubuntu1~20.04.1 [717 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libexpat1 amd64 2.2.9-1build1 [73.3 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-minimal amd64 3.8.10-0ubuntu1~20.04.1 [1900 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-minimal amd64 3.8.2-0ubuntu2 [23.6 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 mime-support all 3.64ubuntu1 [30.6 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libmpdec2 amd64 2.4.2-3 [81.1 kB]
== 줄임 ==
Setting up python3.8 (3.8.10-0ubuntu1~20.04.1) ...
Setting up libpython3-stdlib:amd64 (3.8.2-0ubuntu2) ...
Setting up python3 (3.8.2-0ubuntu2) ...
running python rtupdate hooks for python3.8...
running python post-rtupdate hooks for python3.8...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

# 실행
root@66053458a729:/# python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
반응형