我在运行ubuntu:18.04
的容器内安装了docker,以运行我的nodejs应用程序。我需要在这个容器内安装docker,因为我需要将另一个小型应用程序docker化。
这是我的Dockerfile:
FROM ubuntu:18.04
WORKDIR /app
COPY package*.json ./
# Install Nodejs
RUN apt-get update
RUN apt-get -y install curl wget dirmngr apt-transport-https lsb-release ca-certificates software-properties-common gnupg-agent
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install nodejs
# Install Chromium
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update
RUN apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst \
--no-install-recommends
RUN rm -rf /var/lib/apt/lists/*
# Install Docker
RUN curl -fsSL https:/download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update -y
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
RUN npm install
COPY . .
CMD [ "npm", "start" ]
EXPOSE 3000
当容器启动后,我会运行
docker exec -it app bash
命令。如果我执行 service docker start
然后运行 ps ax
命令,就会得到如下结果。 PID TTY STAT TIME COMMAND
115 ? Z 0:00 [dockerd] <defunct>
我该怎么做才能在容器内使用Docker?或者有没有使用apt-get而不是apk的Docker镜像?因为当我需要使用时,会出现以下错误:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?