Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active August 2, 2025 18:32
Show Gist options
  • Save garystafford/07fbfe8fde48c3f5810c to your computer and use it in GitHub Desktop.
Save garystafford/07fbfe8fde48c3f5810c to your computer and use it in GitHub Desktop.

Revisions

  1. garystafford revised this gist Nov 24, 2014. 3 changed files with 3 additions and 2 deletions.
    1 change: 1 addition & 0 deletions v1-ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ###############################################################################
    # Version 1: using ‘apt-get install’
    # Installs using apt-get
    # Requires update to npm afterwards
    # Harder to get latest copy of node
    1 change: 1 addition & 0 deletions v2-ubuntu-docker-node-make-sh.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ###############################################################################
    # Version 2: using curl, make, and npmjs.org’s install script
    # Installs using make and shell script
    # Easier to update node and npm versions in future
    # Requires sudo to use npm
    3 changes: 1 addition & 2 deletions v3-ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    ###############################################################################
    # Installs using make and shell script
    # Easier to update node and npm versions in future
    # Version 3: version 2 without requiring ‘sudo’ to use npm
    # Does NOT require sudo to use npm
    ###############################################################################

  2. garystafford revised this gist Nov 22, 2014. 1 changed file with 0 additions and 36 deletions.
    36 changes: 0 additions & 36 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -1,36 +0,0 @@
    ###############################################################################
    # Helpful Docker commands to create, start, and stop containers
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    docker pull ubuntu # 1x pull down image ahead of time
    docker run -i -t ubuntu /bin/bash # drops you into container as root

    # list images and containers
    docker images # all images
    docker ps -a # all containers
    docker images | grep <search_term>

    # start and attach to container
    docker start <container>
    docker attach <container>

    # stop and remove container
    docker stop <container>
    docker rm <container>

    #stop and remove ALL containers
    docker stop $(docker ps -a -q)
    docker rm $(docker ps -a -q)
    docker rm $(sudo docker ps --before="<container>" -q) # can also filter

    # remove image (remove assoc. containers first)
    docker rmi <image>
    docker rmi $(docker images | grep <container>)
    docker rmi $(docker images | grep "2 days ago")

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # fix fig / docker config: https://gist.github.com/RuslanHamidullin/94d95328a7360d843e52
  3. garystafford revised this gist Nov 22, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ docker rm $(sudo docker ps --before="<container>" -q) # can also filter
    # remove image (remove assoc. containers first)
    docker rmi <image>
    docker rmi $(docker images | grep <container>)
    docker rmi $(docker images | grep "2 days ago")

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # fix fig / docker config: https://gist.github.com/RuslanHamidullin/94d95328a7360d843e52
  4. garystafford revised this gist Nov 21, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,7 @@ docker rm $(sudo docker ps --before="<container>" -q) # can also filter

    # remove image (remove assoc. containers first)
    docker rmi <image>
    docker rmi $(docker images | grep <container>)

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # fix fig / docker config: https://gist.github.com/RuslanHamidullin/94d95328a7360d843e52
  5. garystafford revised this gist Nov 20, 2014. 1 changed file with 11 additions and 10 deletions.
    21 changes: 11 additions & 10 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -6,28 +6,29 @@
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker pull ubuntu # 1x pull down image ahead of time
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root
    docker pull ubuntu # 1x pull down image ahead of time
    docker run -i -t ubuntu /bin/bash # drops you into container as root

    # list images and containers
    sudo docker images # all images
    sudo docker ps -a # all containers
    docker images # all images
    docker ps -a # all containers
    docker images | grep <search_term>

    # start and attach to container
    sudo docker start <container>
    sudo docker attach <container>
    docker start <container>
    docker attach <container>

    # stop and remove container
    sudo docker stop <container>
    sudo docker rm <container>
    docker stop <container>
    docker rm <container>

    #stop and remove ALL containers
    docker stop $(docker ps -a -q)
    docker rm $(docker ps -a -q)
    sudo docker rm $(sudo docker ps --before="<container>" -q) # can also filter
    docker rm $(sudo docker ps --before="<container>" -q) # can also filter

    # remove image (remove assoc. containers first)
    # sudo docker rmi <image>
    docker rmi <image>

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # fix fig / docker config: https://gist.github.com/RuslanHamidullin/94d95328a7360d843e52
  6. garystafford revised this gist Nov 20, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,5 @@ sudo docker rm $(sudo docker ps --before="<container>" -q) # can also filter
    # remove image (remove assoc. containers first)
    # sudo docker rmi <image>

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    # fix fig / docker config: https://gist.github.com/RuslanHamidullin/94d95328a7360d843e52
  7. garystafford revised this gist Nov 20, 2014. 4 changed files with 12 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,6 @@ docker rm $(docker ps -a -q)
    sudo docker rm $(sudo docker ps --before="<container>" -q) # can also filter

    # remove image (remove assoc. containers first)
    # sudo docker rmi <image>
    # sudo docker rmi <image>

    # other great tips: http://www.centurylinklabs.com/15-quick-docker-tips/
    3 changes: 3 additions & 0 deletions v1-ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,9 @@
    # Requires sudo to use npm
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    3 changes: 3 additions & 0 deletions v2-ubuntu-docker-node-make-sh.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@
    # Requires sudo to use npm
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    3 changes: 3 additions & 0 deletions v3-ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@
    # Does NOT require sudo to use npm
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
  8. garystafford revised this gist Nov 19, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -21,5 +21,10 @@ sudo docker attach <container>
    sudo docker stop <container>
    sudo docker rm <container>

    #stop and remove ALL containers
    docker stop $(docker ps -a -q)
    docker rm $(docker ps -a -q)
    sudo docker rm $(sudo docker ps --before="<container>" -q) # can also filter

    # remove image (remove assoc. containers first)
    # sudo docker rmi <image>
  9. garystafford revised this gist Nov 19, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker pull ubuntu # 1x pull down image ahead of time
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # list images and containers
  10. garystafford revised this gist Nov 19, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # list images and containers
    sudo docker images -a # all images
    sudo docker images # all images
    sudo docker ps -a # all containers

    # start and attach to container
  11. garystafford revised this gist Nov 19, 2014. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion docker-ubuntu-node-npm.sh
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,17 @@
    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # list images and containers
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    # start and attach to container
    sudo docker start <container>
    sudo docker attach <container>

    # stop and remove container
    sudo docker stop <container>
    sudo docker rm <container>
    sudo docker rm <container>

    # remove image (remove assoc. containers first)
    # sudo docker rmi <image>
  12. garystafford revised this gist Nov 18, 2014. 4 changed files with 0 additions and 0 deletions.
    File renamed without changes.
  13. garystafford revised this gist Nov 18, 2014. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion 3-ubuntu-docker-node-git.bash
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ apt-get install -yq g++ libssl-dev apache2-utils curl git python make nano
    # https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
    mkdir ~/node-latest-install && cd $_ && \
    curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
    make install # takes a few minutes to build... && \
    make install && \ # takes a few minutes to build...
    curl https://www.npmjs.org/install.sh | sh

    # add user with sudo privileges within Docker container
    2 changes: 1 addition & 1 deletion 4-ubuntu-docker-node-sudoer.bash
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ mkdir ~/$MODULES
    mkdir ~/node-latest-install && cd $_ && \
    curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
    ./configure --prefix=~/$MODULES && \
    make install # takes a few minutes to build... && \
    make install && \ # takes a few minutes to build...
    curl https://www.npmjs.org/install.sh | sh

    # install common fullstack JavaScript packages globally
  14. garystafford revised this gist Nov 18, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 2-ubuntu-docker-node-apt-get.bash
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@
    apt-get update -yq && apt-get upgrade -yq && \
    apt-get install -yq curl git nano

    # install from nodesource using apt-get
    # https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server
    curl -sL https://deb.nodesource.com/setup | sudo bash - && \
    apt-get install -yq nodejs build-essential

  15. garystafford revised this gist Nov 18, 2014. 4 changed files with 0 additions and 0 deletions.
    File renamed without changes.
  16. garystafford revised this gist Nov 18, 2014. 4 changed files with 11 additions and 7 deletions.
    2 changes: 1 addition & 1 deletion 0-docker-ubuntu-node-npm → 1-docker-ubuntu-node-npm
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ###############################################################################
    # Helpful Docker commands to create, start, and stop containers #
    # Helpful Docker commands to create, start, and stop containers
    ###############################################################################

    # install docker first using directions for installing latest version
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    ###############################################################################
    # Installs using apt-get. Requires update to npm afterwards. #
    # Requires sudo to use npm. #
    # Installs using apt-get
    # Requires update to npm afterwards
    # Harder to get latest copy of node
    # Requires sudo to use npm
    ###############################################################################

    # update and install all required packages (no sudo required as root)
    5 changes: 3 additions & 2 deletions 2-ubuntu-docker-node-git.sh → 3-ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future #
    # Requires sudo to use npm. #
    # Installs using make and shell script
    # Easier to update node and npm versions in future
    # Requires sudo to use npm
    ###############################################################################

    # update and install all required packages (no sudo required as root)
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future. #
    # Does not require sudo to use npm. #
    # Installs using make and shell script
    # Easier to update node and npm versions in future
    # Does NOT require sudo to use npm
    ###############################################################################

    # update and install all required packages (no sudo required as root)
  17. garystafford renamed this gist Nov 18, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. garystafford revised this gist Nov 18, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion 0-helpful-docker-commands.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@
    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

  19. garystafford revised this gist Nov 18, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions 0-helpful-docker-commands.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future #
    # Requires sudo to use npm. #
    # Helpful Docker commands to create, start, and stop containers #
    ###############################################################################

    # install docker first using directions for installing latest version
  20. garystafford revised this gist Nov 18, 2014. 4 changed files with 3 additions and 9 deletions.
    3 changes: 3 additions & 0 deletions 0-helpful-docker-commands.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,9 @@
    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers
    3 changes: 0 additions & 3 deletions 1-ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Requires sudo to use npm. #
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    3 changes: 0 additions & 3 deletions 2-ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Requires sudo to use npm. #
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    3 changes: 0 additions & 3 deletions 3-ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Does not require sudo to use npm. #
    ###############################################################################

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
  21. garystafford revised this gist Nov 18, 2014. 4 changed files with 20 additions and 42 deletions.
    17 changes: 17 additions & 0 deletions 0-helpful-docker-commands.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future #
    # Requires sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Requires sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    @@ -35,14 +32,4 @@ sudo npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
    npm ls -g --depth=0
    15 changes: 1 addition & 14 deletions ubuntu-docker-node-git.sh → 2-ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Requires sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    @@ -36,14 +33,4 @@ sudo npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
    npm ls -g --depth=0
    15 changes: 1 addition & 14 deletions ubuntu-docker-node-sudoer.sh → 3-ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,6 @@
    # Does not require sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    @@ -44,14 +41,4 @@ npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
    npm ls -g --depth=0
  22. garystafford revised this gist Nov 18, 2014. 2 changed files with 4 additions and 2 deletions.
    3 changes: 2 additions & 1 deletion ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    ###############################################################################
    # Installs using apt-get. Requires update to npm afterwards. #
    # Requires sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    @@ -30,7 +31,7 @@ su - $USER # switch to testuser

    # install common full-stack JavaScript packages globally
    # http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
    npm install -g yo grunt-cli bower express
    sudo npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    3 changes: 2 additions & 1 deletion ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future #
    # Requires sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    @@ -31,7 +32,7 @@ su - $USER # switch to testuser

    # install common full-stack JavaScript packages globally
    # http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
    npm install -g yo grunt-cli bower express
    sudo npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
  23. garystafford revised this gist Nov 18, 2014. 3 changed files with 13 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    ###############################################################################
    # Installs using apt-get. Requires update to npm afterwards. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    4 changes: 4 additions & 0 deletions ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    5 changes: 5 additions & 0 deletions ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    ###############################################################################
    # Installs using apt-get. Easier to update node version in future. #
    # Does not require sudo to use npm. #
    ###############################################################################

    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

  24. garystafford revised this gist Nov 18, 2014. 1 changed file with 52 additions and 0 deletions.
    52 changes: 52 additions & 0 deletions ubuntu-docker-node-sudoer.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    apt-get install -yq g++ libssl-dev apache2-utils curl git python make nano

    # add user with sudo privileges within Docker container
    # without adduser input questions
    # http://askubuntu.com/questions/94060/run-adduser-non-interactively/94067#94067
    USER="testuser" && \
    adduser --disabled-password --gecos "" $USER && \
    sudo usermod -a -G sudo $USER && \
    echo "$USER:abc123" | chpasswd && \
    su - $USER # switch to testuser

    # setting up npm for global installation without sudo
    # http://stackoverflow.com/a/19379795/580268
    MODULES="local" && \
    echo prefix = ~/$MODULES >> ~/.npmrc && \
    echo "export PATH=\$HOME/$MODULES/bin:\$PATH" >> ~/.bashrc && \
    . ~/.bashrc && \
    mkdir ~/$MODULES

    # install Node.js and npm
    # https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
    mkdir ~/node-latest-install && cd $_ && \
    curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
    ./configure --prefix=~/$MODULES && \
    make install # takes a few minutes to build... && \
    curl https://www.npmjs.org/install.sh | sh

    # install common fullstack JavaScript packages globally
    npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
  25. garystafford revised this gist Nov 18, 2014. 1 changed file with 43 additions and 0 deletions.
    43 changes: 43 additions & 0 deletions ubuntu-docker-node-apt-get.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    apt-get install -yq curl git nano

    curl -sL https://deb.nodesource.com/setup | sudo bash - && \
    apt-get install -yq nodejs build-essential

    # fix npm - not the latest version installed by apt-get
    npm install -g npm

    # add user with sudo privileges within Docker container
    # without adduser input questions
    # http://askubuntu.com/questions/94060/run-adduser-non-interactively/94067#94067
    USER="testuser" && \
    adduser --disabled-password --gecos "" $USER && \
    sudo usermod -a -G sudo $USER && \
    echo "$USER:abc123" | chpasswd && \
    su - $USER # switch to testuser

    # install common full-stack JavaScript packages globally
    # http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
    npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>
  26. garystafford revised this gist Nov 18, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,6 @@ apt-get install -yq g++ libssl-dev apache2-utils curl git python make nano
    # https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
    mkdir ~/node-latest-install && cd $_ && \
    curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
    ./configure --prefix=~/$MODULES && \
    make install # takes a few minutes to build... && \
    curl https://www.npmjs.org/install.sh | sh

  27. garystafford created this gist Nov 18, 2014.
    45 changes: 45 additions & 0 deletions ubuntu-docker-node-git.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # install docker first using directions for installing latest version
    # https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

    # create new docker ubuntu container
    sudo docker run -i -t ubuntu /bin/bash # drops you into container as root

    # update and install all required packages (no sudo required as root)
    # https://gist.github.com/isaacs/579814#file-only-git-all-the-way-sh
    apt-get update -yq && apt-get upgrade -yq && \
    apt-get install -yq g++ libssl-dev apache2-utils curl git python make nano

    # install latest Node.js and npm
    # https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
    mkdir ~/node-latest-install && cd $_ && \
    curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
    ./configure --prefix=~/$MODULES && \
    make install # takes a few minutes to build... && \
    curl https://www.npmjs.org/install.sh | sh

    # add user with sudo privileges within Docker container
    # without adduser input questions
    # http://askubuntu.com/questions/94060/run-adduser-non-interactively/94067#94067
    USER="testuser" && \
    adduser --disabled-password --gecos "" $USER && \
    sudo usermod -a -G sudo $USER && \
    echo "$USER:abc123" | chpasswd && \
    su - $USER # switch to testuser

    # install common full-stack JavaScript packages globally
    # http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
    npm install -g yo grunt-cli bower express

    # optional, check locations and packages are correct
    which node; node -v; which npm; npm -v; \
    npm ls -g --depth=0

    # helpful docker commands
    sudo docker images -a # all images
    sudo docker ps -a # all containers

    sudo docker start <container>
    sudo docker attach <container>

    sudo docker stop <container>
    sudo docker rm <container>