0

I'm currently trying to reduce the docker image size for my project and I started to do so by using the node:alpine image. I've started to run into a problem however, where I can't perform any docker commands from within the initial docker container. The command I'm running is:

docker inspect --format '{{ range .Mounts }}{{ if eq .Destination "/database" }}{{ .Source }}{{ end }}{{ end }}' MyContainer

When I try to run that command I get /bin/sh: docker: not found as an error. I'm using a Dockerfile to create the initial container, which looks like this:

FROM node:alpine
RUN apk add docker
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 7000
CMD [ "npm", "run", "startpro"]

I am not too sure if maybe I'm installing docker wrong or if docker in docker isn't supported within the node:alpine image. This was all working when I was using the node:latest image.

Any advice would be much appreciated.

Erik Pohle
  • 1
  • 1
  • 1
  • It looks like you don't have docker installed. Which OS are you using to run docker? – Marko E Aug 12 '20 at 19:47
  • I'm using Linux. – Erik Pohle Aug 13 '20 at 21:16
  • Try installing Docker CE first, as it seems to me the needed packages aren't installed: https://docs.docker.com/get-docker/. – Marko E Aug 13 '20 at 21:50
  • I have Docker CE installed, but it still doesn't work... Same error. – Erik Pohle Aug 14 '20 at 16:19
  • Ah, sorry, I just reread the question. You want to run docker inside of a docker. Any particular reason for that? – Marko E Aug 14 '20 at 18:00
  • This is for a simulation project. I need the ability to launch more containers from within a single container, since it'll be running from a parent-container when in production mode. So essentially, that docker inspect command needs to be able to function from within a parent container, but right now, it can't find docker. – Erik Pohle Aug 14 '20 at 19:40
  • Looking at the documentation, it seem that Alpine requires some additional steps to configure Docker: https://stackoverflow.com/questions/54099218/how-can-i-install-docker-inside-an-alpine-container. – Marko E Aug 14 '20 at 19:51
  • I've attempted that as well, but it gives me the same error. No docker found. – Erik Pohle Aug 14 '20 at 20:02

0 Answers0