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 1 year has passed since last update.

Dockerfile で asdf: command not found

Last updated at Posted at 2023-08-07

環境

  • nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04

問題

Dockerfile において asdf をインストールした後,同 Dockerfile で asdf が実行できないエラーが生じる場合がある12
source ~/.bashrc を行うことで,このエラーが出なくなる場合もあるらしいが,本環境では,改善しなかった.

Dockerfileの抜粋

SHELL ["/bin/bash", "-c"]
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3
RUN echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc \
&& echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc \
&& RUN source ~/.bashrc \
&& asdf plugin add python \
&& asdf install python 3.10.0 \
&& asdf global python 3.10.0 \

生じるエラー

asdf: command not found

解決策

直接,環境変数としてパスを設定することによって解決した.
原因は,Dockerfile では RUN ごとに異なるシェルが実行されることか2

RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3
RUN echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc \
&& echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc 

# 追加
ENV PATH="/root/.asdf/shims:/root/.asdf/bin:${PATH}"

RUN source ~/.bashrc \
&& asdf plugin add python \
&& asdf install python 3.10.0 \
&& asdf global python 3.10.0 \
  1. Can install asdf inside Docker container, but not at build time via Dockerfile

  2. Dockerfileでasdfを実行できないことについて 2

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?