Please feel free to create an issue or open a pull request if you need support or would like to contribute.
node
, package managers and build tools2019-02-25
node
v11 images and testsnode-11-alpine
image (you can always use the DOCKER_NPM_TAG
variable to use another image).Images are tagged according to the installed Node version and operating system. Package versions are not pinned, instead npm
is executed to install current versions of each package. If stability issues aries, I will pin package versions in a Dockerfile
for that Node/OS version and create a image tagged as stable
based on it. Please let me know if you run into this situation.
alpine
, latest
DockerfileBased on node:alpine
. This image should be considered under development and may not be as stable as versioned images.
node-11-alpine
DockerfileBased on node:11-alpine
.
node-10-alpine
DockerfileBased on node:10-alpine
.
node-9-alpine
DockerfileBased on node:9-alpine
.
node-8-alpine
DockerfileBased on node:8-alpine
.
node-7-alpine
DockerfileBased on node:7-alpine
.
node-6-alpine
DockerfileBased on node:6-alpine
.
debian
DockerfileBased on node:latest
. This image should be considered under development and may not be as stable as versioned images.
node-11-debian
DockerfileBased on node:11-stretch
.
node-10-debian
DockerfileBased on node:10-wheezy
.
node-9-debian
DockerfileBased on node:9-wheezy
.
node-8-debian
DockerfileBased on node:8-wheezy
.
node-7-debian
DockerfileBased onnode:7-wheezy
.
node-7.7-alpine
, 7.0-alpine
Dockerfile Based on node:7.7-alpine
, it node
v7.7 compiled from source. The 7.0-alpine
tagged version was accidentally upgraded over time to v7.7 and will remain so for the stability of existing users.
node-6.9-alpine
, 6.9-alpine
Dockerfile Based on alpine:3.4
with node
v6.9 compiled from source.
node-7.0-debian
, 7.0-debian
Dockerfile Based onnode:7.0-wheezy
.
node-6.9-debian
, 6.9-debian
Dockerfile Based onnode:6.9-wheezy
.
Essentially, this is just a set of shell scripts that manage a Node.js docker image. The docker image includes a script (run-as-user
) that allows commands to write files as either the current user or the owner/group of the current directory, which the shell scripts take advantage of to make sure files are created with your preferred permissions rather than root.
The images contain the latest stable bower
, generate-md
, grunt
, gulp
, node
, npm
, npx
, and yarn
, binaries for node
. When using the shell scripts available in the source repository, the current directory is mounted into /src
inside the container and a wrapper script executes the specified command as a user who's uid
and gid
matches those properties on that directory. This way any output is written as the directory owner/group instead of root or a random user.
The included run-as-user
script has three methods of determining which uid
and gid
to execute as:
By default, it will execute with a uid
and gid
that matches the current directory (the one that gets mounted into /src
).
In order to take advantage of public key authentication when installing packages from private repositories, all the wrapper scripts will attempt to mount your ~/.ssh
directory into the container. When that is successful, the script will run as the uid
and gid
of the owner of ~/.ssh
(you).
Most software that takes advantage of public key authentication protocols do so over SSH, and by default, send the current user name as the login name. Because this process is executing out of a segregated container, it knows nothing about the current user's name and will instead try to login as a user named dev
. In order to work around this, you need to create a SSH configuration that specifies the correct username.
In your ~/.ssh
folder create a file called config
. In that file you need to specify the correct username. For example, to specify your login name for all hosts:
Host *
User mkenney
You can easily be more explicit as well, specifying by host or with additional wildcards. Google is your friend.
Host github.com
User mkenney
You can also explicitly specify the uid
and gid
to use at runtime by defining the PUID
and PGID
environment variables when executing the container, this is quite useful in automated build systems:
docker run \
--rm \
-it \
-v $(pwd):/src:rw \
-e "PUID=<user id>" \
-e "PGID=<group id>" \
mkenney/npm:latest <commands>
The included wrapper scripts default to the latest node version and image tag I feel is stable, I will update the default tag as updates are released or stability issues warrant (node-10-alpine
at the moment).
To specify a different image, you can define the image tag in your environment which will set a new default (you probably want to define this in your .bashrc
or similar profile script):
export DOCKER_NPM_TAG=node-6.9-alpine
or you can easily specify it at runtime whenever necessary, for example:
$ DOCKER_NPM_TAG=node-6.9-alpine bower install
If you would to see like additional node modules and/or wrapper scripts added to this project please feel free to create an issue or open a pull request.
This assumes that you already have Docker installed. A running docker
daemon is required. You probably want to be able to run docker commands without sudo, but even if you excute the scripts with sudo files will be written with the appropriate uid
and gid
.
Wrapper scripts for several commands are available in the source repository:
Installation is just a matter of putting them somewhere in your path and making them executable. An installation script is available and can be executed with a shell curl
+sh -s
command. Simply pass in your command arguments normally.
Usage
install.sh COMMAND [TAG [PREFIX]]
Synopsys
Install a mkenney/npm container execution script locally
Options
COMMAND - Required, the name of the command to install (bower, gulp, npm, etc.)
TAG - Optional, the image tag to use. Default 'latest'
PREFIX - Optional, the location to install the command script. Default '$HOME/bin'
Examples
$ curl -L https://raw.githubusercontent.com/mkenney/docker-npm/master/bin/install.sh | bash -s gulp node-10-alpine $HOME/bin
$ bash ./install.sh gulp node-10-alpine $HOME/bin
[command] self-update
Each of the scripts have a self-update
command which pulls down the latest docker image (which all the scripts share) and then updates the shell script itself. If you don't have write permissions on the shell script you'll get a permissions error, you can run the self-update command with sudo
if necessary.
1、环境 服务器:CentOS Linux release 7.6.1810 (Core) + docker 19.03.8+ 2、认识或者安装 Verdaccio: 一个轻量级的Node.js私有代理注册表 官网:https://verdaccio.org/ 安装: docker pull verdaccio/verdaccio 3、 创建项目结构和文件 -warehouse -docke
一、手动安装docker 安装基础的工具yum-utils device-mapper-persistent-data lvm2 yum install -y yum-utils device-mapper-persistent-data lvm2 添加docker-ce yum仓库 因为在阿里云的ecs机器上面,yum镜像使用的阿里云的,找不到docker的镜像,所以需要第一步的安装基础工具之后
1.目录结构 docker-compose.yaml Dockerfile egg 2.docker-compose.yaml version: '2' services: egg_test: build: . ports: - "3002:7001" 3.Dockerfile FROM node:16.3.0 RUN mkdir -p /home/dock
受限于node环境的苦恼,写了一个通用的docker-compose脚本。 作用:可灵活切换node版本,一件部署。 操作流程: 在node项目(Vue、react)工作目录下创建DockerFile和docker-compose.yml文件 在DockerFile中输入对应内容(下面给出,可以固定化) 在docker-compose.yml中输入内容(下面给出,也强标注了对应命令) 运行dock
目录 MySQL 8.0 Dockerfile 例子:MySQL 容器自建数据库 docker-entrypoint.sh 的用处 再举个例子 很多著名库的 Dockerfile 文件中,通常都是 ENTRYPOINT 字段会是这样: ENTRYPOINT ["docker-entrypoint.sh"] 这里我们参考分析下 MySQL 的 Dockerfile 文件,来认识下 docker-e
1.安装docker 跳转此链接:docker安装 2.安装docker-compose # 下载docker compose 使用giehub安装较慢推荐使用daocloud安装 [root@localhost ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.1/docker-compose-
how to use docker-compose! version: "2" services: webapp: image: "node:latest" user: "root" working_dir: "/home/app" ports: [8090:4000] volumes: - /mydata/data/blog/
问题内容: 我有一个在Docker容器中运行的应用程序。它需要公司私有NPM注册表(Sinopia)中的一些私有模块,访问这些模块需要用户身份验证。Dockerfile是。 我努力了: 1)创造在项目的根的.npmrc文件,这其实没有什么区别和NPM似乎使用ENV变量忽略它2) ,等等,但用户不登录。 本质上,我似乎无法在此过程中对用户进行身份验证。我希望有人可能已经遇到了这个问题(似乎是一个显而
一、解决的问题 二、与虚拟机的比较 三、优势 四、使用场景 五、镜像与容器 参考资料 一、解决的问题 由于不同的机器有不同的操作系统,以及不同的库和组件,在将一个应用部署到多台机器上需要进行大量的环境配置操作。 Docker 主要解决环境配置问题,它是一种虚拟化技术,对进程进行隔离,被隔离的进程独立于宿主操作系统和其它隔离的进程。使用 Docker 可以不修改应用程序代码,不需要开发人员学习特定环
我检查了垃圾箱,里面没有ping
第一章 Docker介绍1 1.1 docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的\[Linux\]机器上,也可以实现\[虚拟化\]。容器是完全使用\[沙箱\]机制,相互之间不会有任何接口。 1.2 Docker是什么? Docker是一个程序运行、测试、交付的开放平台,Docker被设计为能够使你快速地交
推荐使用 Swoole 官方 Docker:https://github.com/swoole/docker-swoole
Docker Commands Commands Notes docker ps -a Show all containers on the system docker ps Show only currently running containers docker run <NAME> Creates & runs a docker container via an image docker i