Source configs debian docker












0















I am trying to create an NVM base dockerfile from a debian base and I am unable to make node available on non-interactive shells (i.e no entrypoint with just a command)
Here is my Dockerfile:



ARG DEBIAN_VERSION=stable-slim

FROM library/debian:${DEBIAN_VERSION}

###########################################################################
# Core requirements
###########################################################################

# Install "libraries", "Software's"
RUN apt-get update &&
apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends
git
curl
locales
build-essential
ca-certificates &&
apt-get clean &&
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&
rm /var/log/lastlog /var/log/faillog

###########################################################################
# Creating non-root user:
###########################################################################

# Add a non-root user to prevent files being created with root permissions on host machine.
ARG PUID=1000
ENV PUID ${PUID}
ARG PGID=1000
ENV PGID ${PGID}
ARG GROUP_NAME=nvm
ARG USER_NAME=nvm

RUN groupadd -g ${PGID} ${GROUP_NAME} &&
useradd --uid ${PUID} --gid ${GROUP_NAME} --shell /bin/bash --create-home ${USER_NAME} &&
echo '${USER_NAME} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

###########################################################################
# Set Timezone & Locale
###########################################################################

ARG TZ=AEST
ENV TZ ${TZ}

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &&
echo $TZ > /etc/timezone &&
locale-gen en_US.UTF-8

# Make sure to load the profile on interactive and non-interactive shells
ENV BASH_ENV=/etc/profile

###########################################################################
# Node / NVM:
###########################################################################

# Check if NVM needs to be installed
ARG NVM_VERSION=node
ENV NODE_VERSION ${NODE_VERSION}
ARG INSTALL_NODE=true

# Move to entrypoint script
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
# Move to entrypoint script

ENV NVM_DIR /home/${USER_NAME}/.nvm

RUN if [ ${INSTALL_NODE} = true ]; then
# Install nvm (A Node Version Manager)
mkdir $NVM_DIR &&
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash &&
. $NVM_DIR/nvm.sh &&
nvm install $NVM_VERSION &&
nvm use $NVM_VERSION &&
NODE_VERSION=$(node --version) &&
nvm alias default $NODE_VERSION &&
if [ ${NPM_REGISTRY} ]; then
npm config set registry ${NPM_REGISTRY}
;fi &&
chown -R ${GROUP_NAME}:${USER_NAME} $NVM_DIR &&
echo "export PATH=$PATH:$NVM_DIR/versions/node/${NODE_VERSION}/bin" >> /etc/profile &&
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /etc/profile &&
echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> /etc/profile
;fi

RUN ln -sf /bin/bash /bin/sh
ENV SHELL /bin/bash
# Set default work directory
WORKDIR /var/application
# Set Default user as application user
USER $USER_NAME


The only method that gave me any success was to have both:



ENV BASH_ENV=/etc/profile
ENTRYPOINT ["/bin/bash", "-c"]


But this is not ideal, I have tried to have the relevant lines as part of all the files listen in: this question
And it works successfully if i use



docker exec -it nvm bash
~ node --version


But does not work if I do:



docker exec nvm node --version


Can anyone explain what I may be missing here?










share|improve this question







New contributor




Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I am trying to create an NVM base dockerfile from a debian base and I am unable to make node available on non-interactive shells (i.e no entrypoint with just a command)
    Here is my Dockerfile:



    ARG DEBIAN_VERSION=stable-slim

    FROM library/debian:${DEBIAN_VERSION}

    ###########################################################################
    # Core requirements
    ###########################################################################

    # Install "libraries", "Software's"
    RUN apt-get update &&
    apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends
    git
    curl
    locales
    build-essential
    ca-certificates &&
    apt-get clean &&
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&
    rm /var/log/lastlog /var/log/faillog

    ###########################################################################
    # Creating non-root user:
    ###########################################################################

    # Add a non-root user to prevent files being created with root permissions on host machine.
    ARG PUID=1000
    ENV PUID ${PUID}
    ARG PGID=1000
    ENV PGID ${PGID}
    ARG GROUP_NAME=nvm
    ARG USER_NAME=nvm

    RUN groupadd -g ${PGID} ${GROUP_NAME} &&
    useradd --uid ${PUID} --gid ${GROUP_NAME} --shell /bin/bash --create-home ${USER_NAME} &&
    echo '${USER_NAME} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

    ###########################################################################
    # Set Timezone & Locale
    ###########################################################################

    ARG TZ=AEST
    ENV TZ ${TZ}

    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &&
    echo $TZ > /etc/timezone &&
    locale-gen en_US.UTF-8

    # Make sure to load the profile on interactive and non-interactive shells
    ENV BASH_ENV=/etc/profile

    ###########################################################################
    # Node / NVM:
    ###########################################################################

    # Check if NVM needs to be installed
    ARG NVM_VERSION=node
    ENV NODE_VERSION ${NODE_VERSION}
    ARG INSTALL_NODE=true

    # Move to entrypoint script
    ARG NPM_REGISTRY
    ENV NPM_REGISTRY ${NPM_REGISTRY}
    # Move to entrypoint script

    ENV NVM_DIR /home/${USER_NAME}/.nvm

    RUN if [ ${INSTALL_NODE} = true ]; then
    # Install nvm (A Node Version Manager)
    mkdir $NVM_DIR &&
    curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash &&
    . $NVM_DIR/nvm.sh &&
    nvm install $NVM_VERSION &&
    nvm use $NVM_VERSION &&
    NODE_VERSION=$(node --version) &&
    nvm alias default $NODE_VERSION &&
    if [ ${NPM_REGISTRY} ]; then
    npm config set registry ${NPM_REGISTRY}
    ;fi &&
    chown -R ${GROUP_NAME}:${USER_NAME} $NVM_DIR &&
    echo "export PATH=$PATH:$NVM_DIR/versions/node/${NODE_VERSION}/bin" >> /etc/profile &&
    echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /etc/profile &&
    echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> /etc/profile
    ;fi

    RUN ln -sf /bin/bash /bin/sh
    ENV SHELL /bin/bash
    # Set default work directory
    WORKDIR /var/application
    # Set Default user as application user
    USER $USER_NAME


    The only method that gave me any success was to have both:



    ENV BASH_ENV=/etc/profile
    ENTRYPOINT ["/bin/bash", "-c"]


    But this is not ideal, I have tried to have the relevant lines as part of all the files listen in: this question
    And it works successfully if i use



    docker exec -it nvm bash
    ~ node --version


    But does not work if I do:



    docker exec nvm node --version


    Can anyone explain what I may be missing here?










    share|improve this question







    New contributor




    Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I am trying to create an NVM base dockerfile from a debian base and I am unable to make node available on non-interactive shells (i.e no entrypoint with just a command)
      Here is my Dockerfile:



      ARG DEBIAN_VERSION=stable-slim

      FROM library/debian:${DEBIAN_VERSION}

      ###########################################################################
      # Core requirements
      ###########################################################################

      # Install "libraries", "Software's"
      RUN apt-get update &&
      apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends
      git
      curl
      locales
      build-essential
      ca-certificates &&
      apt-get clean &&
      rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&
      rm /var/log/lastlog /var/log/faillog

      ###########################################################################
      # Creating non-root user:
      ###########################################################################

      # Add a non-root user to prevent files being created with root permissions on host machine.
      ARG PUID=1000
      ENV PUID ${PUID}
      ARG PGID=1000
      ENV PGID ${PGID}
      ARG GROUP_NAME=nvm
      ARG USER_NAME=nvm

      RUN groupadd -g ${PGID} ${GROUP_NAME} &&
      useradd --uid ${PUID} --gid ${GROUP_NAME} --shell /bin/bash --create-home ${USER_NAME} &&
      echo '${USER_NAME} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

      ###########################################################################
      # Set Timezone & Locale
      ###########################################################################

      ARG TZ=AEST
      ENV TZ ${TZ}

      RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &&
      echo $TZ > /etc/timezone &&
      locale-gen en_US.UTF-8

      # Make sure to load the profile on interactive and non-interactive shells
      ENV BASH_ENV=/etc/profile

      ###########################################################################
      # Node / NVM:
      ###########################################################################

      # Check if NVM needs to be installed
      ARG NVM_VERSION=node
      ENV NODE_VERSION ${NODE_VERSION}
      ARG INSTALL_NODE=true

      # Move to entrypoint script
      ARG NPM_REGISTRY
      ENV NPM_REGISTRY ${NPM_REGISTRY}
      # Move to entrypoint script

      ENV NVM_DIR /home/${USER_NAME}/.nvm

      RUN if [ ${INSTALL_NODE} = true ]; then
      # Install nvm (A Node Version Manager)
      mkdir $NVM_DIR &&
      curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash &&
      . $NVM_DIR/nvm.sh &&
      nvm install $NVM_VERSION &&
      nvm use $NVM_VERSION &&
      NODE_VERSION=$(node --version) &&
      nvm alias default $NODE_VERSION &&
      if [ ${NPM_REGISTRY} ]; then
      npm config set registry ${NPM_REGISTRY}
      ;fi &&
      chown -R ${GROUP_NAME}:${USER_NAME} $NVM_DIR &&
      echo "export PATH=$PATH:$NVM_DIR/versions/node/${NODE_VERSION}/bin" >> /etc/profile &&
      echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /etc/profile &&
      echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> /etc/profile
      ;fi

      RUN ln -sf /bin/bash /bin/sh
      ENV SHELL /bin/bash
      # Set default work directory
      WORKDIR /var/application
      # Set Default user as application user
      USER $USER_NAME


      The only method that gave me any success was to have both:



      ENV BASH_ENV=/etc/profile
      ENTRYPOINT ["/bin/bash", "-c"]


      But this is not ideal, I have tried to have the relevant lines as part of all the files listen in: this question
      And it works successfully if i use



      docker exec -it nvm bash
      ~ node --version


      But does not work if I do:



      docker exec nvm node --version


      Can anyone explain what I may be missing here?










      share|improve this question







      New contributor




      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am trying to create an NVM base dockerfile from a debian base and I am unable to make node available on non-interactive shells (i.e no entrypoint with just a command)
      Here is my Dockerfile:



      ARG DEBIAN_VERSION=stable-slim

      FROM library/debian:${DEBIAN_VERSION}

      ###########################################################################
      # Core requirements
      ###########################################################################

      # Install "libraries", "Software's"
      RUN apt-get update &&
      apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends
      git
      curl
      locales
      build-essential
      ca-certificates &&
      apt-get clean &&
      rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&
      rm /var/log/lastlog /var/log/faillog

      ###########################################################################
      # Creating non-root user:
      ###########################################################################

      # Add a non-root user to prevent files being created with root permissions on host machine.
      ARG PUID=1000
      ENV PUID ${PUID}
      ARG PGID=1000
      ENV PGID ${PGID}
      ARG GROUP_NAME=nvm
      ARG USER_NAME=nvm

      RUN groupadd -g ${PGID} ${GROUP_NAME} &&
      useradd --uid ${PUID} --gid ${GROUP_NAME} --shell /bin/bash --create-home ${USER_NAME} &&
      echo '${USER_NAME} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

      ###########################################################################
      # Set Timezone & Locale
      ###########################################################################

      ARG TZ=AEST
      ENV TZ ${TZ}

      RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &&
      echo $TZ > /etc/timezone &&
      locale-gen en_US.UTF-8

      # Make sure to load the profile on interactive and non-interactive shells
      ENV BASH_ENV=/etc/profile

      ###########################################################################
      # Node / NVM:
      ###########################################################################

      # Check if NVM needs to be installed
      ARG NVM_VERSION=node
      ENV NODE_VERSION ${NODE_VERSION}
      ARG INSTALL_NODE=true

      # Move to entrypoint script
      ARG NPM_REGISTRY
      ENV NPM_REGISTRY ${NPM_REGISTRY}
      # Move to entrypoint script

      ENV NVM_DIR /home/${USER_NAME}/.nvm

      RUN if [ ${INSTALL_NODE} = true ]; then
      # Install nvm (A Node Version Manager)
      mkdir $NVM_DIR &&
      curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash &&
      . $NVM_DIR/nvm.sh &&
      nvm install $NVM_VERSION &&
      nvm use $NVM_VERSION &&
      NODE_VERSION=$(node --version) &&
      nvm alias default $NODE_VERSION &&
      if [ ${NPM_REGISTRY} ]; then
      npm config set registry ${NPM_REGISTRY}
      ;fi &&
      chown -R ${GROUP_NAME}:${USER_NAME} $NVM_DIR &&
      echo "export PATH=$PATH:$NVM_DIR/versions/node/${NODE_VERSION}/bin" >> /etc/profile &&
      echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /etc/profile &&
      echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> /etc/profile
      ;fi

      RUN ln -sf /bin/bash /bin/sh
      ENV SHELL /bin/bash
      # Set default work directory
      WORKDIR /var/application
      # Set Default user as application user
      USER $USER_NAME


      The only method that gave me any success was to have both:



      ENV BASH_ENV=/etc/profile
      ENTRYPOINT ["/bin/bash", "-c"]


      But this is not ideal, I have tried to have the relevant lines as part of all the files listen in: this question
      And it works successfully if i use



      docker exec -it nvm bash
      ~ node --version


      But does not work if I do:



      docker exec nvm node --version


      Can anyone explain what I may be missing here?







      debian shell docker






      share|improve this question







      New contributor




      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 11 mins ago









      Kieran WilsonKieran Wilson

      1




      1




      New contributor




      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Kieran Wilson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Kieran Wilson is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f501281%2fsource-configs-debian-docker%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Kieran Wilson is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Kieran Wilson is a new contributor. Be nice, and check out our Code of Conduct.













          Kieran Wilson is a new contributor. Be nice, and check out our Code of Conduct.












          Kieran Wilson is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f501281%2fsource-configs-debian-docker%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          サソリ

          広島県道265号伴広島線

          Accessing regular linux commands in Huawei's Dopra Linux