0

我已经设置了一个非 root 用户,并且在构建我的开发容器时遇到了这些错误。如果我删除 root 用户,它运行良好。这些步骤在安装后列出。

以下是我在终端中收到的错误。

Error: Command failed: /bin/sh -c gem install bundler -v 1.17.3 && bundle install && rake db:create && rake db:migrate && rake assets:precompile && rake db:seed
Start: Run in container: /bin/sh -c gem install bundler -v 1.17.3 && bundle install && rake db:create && rake db:migrate && rake assets:precompile && rake db:seed
/bin/sh: 1: gem: not found

Dockerfile

FROM ubuntu:19.04
ENV DEBIAN_FRONTEND=noninteractive

# TODO: it would be nice to use the vscode user instead.
#  until then we silence the warning.
ENV BUNDLE_SILENCE_ROOT_WARNING = true

# fix sources
RUN sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/old-releases.ubuntu.com/' /etc/apt/sources.list

# TRICKY: this has to be installed first
RUN apt-get update -q && apt-get install -y build-essential ssh-client

# add older repository so we can get libssl1.0-dev
RUN echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' >> /etc/apt/sources.list

# Add non-root user.
ARG USERNAME=vscode
ARG USER_UID=1001
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
    #
    # [Optional] Add sudo support. Omit if you don't need to install software after connecting.
    && apt-get update \
    && apt-get install -y sudo \
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME

# update packages
RUN apt-get update -q && \
    apt-cache policy libssl1.0-dev && \
    apt-get install -y --no-install-recommends \
        tzdata git vim iputils-ping apt-utils procps ca-certificates gnupg2 curl wget && \
    apt-get clean

# install RVM
RUN gpg2 --keyserver keyserver.ubuntu.com --recv-keys D39DC0E3 39499BDB
RUN curl -sSL https://get.rvm.io | bash -s stable

# Add user to RVM.
RUN usermod -a -G rvm $USERNAME

# Set the default user. 
USER $USERNAME

SHELL ["/bin/bash", "-l", "-c"]
RUN echo 'source /etc/profile' >> ~/.bashrc

# install ruby
RUN rvm install 2.3.8

# install bundler
RUN gem install bundler -v 1.17.3

# install application dependencies
# TRICKY: these must be installed last
RUN sudo apt-get install -y nodejs=10.15.2~dfsg-1 libcups2-dev libmysqlclient-dev libmagickwand-dev mysql-client redis-server
4

0 回答 0