0

I am trying to build a Docker image where Lando should be preinstalled.

My Dockerfile looks like :

FROM devwithlando/php:7.1-fpm

RUN apt-get update -y \
  && docker-php-ext-install pcntl
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update
RUN apt-get install -y docker-ce
#RUN usermod -aG docker ${USER}
RUN apt-get update
RUN curl -fsSL -o /tmp/lando-latest.deb http://installer.kalabox.io/lando-latest-dev.deb
RUN dpkg -i /tmp/lando-latest.deb
RUN lando version

But It's showing "lando command not found", Is anything I am missing, Please guide me.

user3483203
  • 50,081
  • 9
  • 65
  • 94
visabhishek
  • 113
  • 2
  • 11
  • Do you really get that far? Your dockerfile fails before that for me. – user3483203 Jun 04 '18 at 14:04
  • It's not necessarily bad to install docker inside of docker. There are situations it's appropriate. – user3483203 Jun 04 '18 at 14:41
  • @visabhishek I tried building your Dockerfile and it fails for me at `Step 4/10 : RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" ---> Running in fa27b4eb1beb /bin/sh: 1: add-apt-repository: not found The command '/bin/sh -c add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"' returned a non-zero code: 127` – emory Jun 04 '18 at 16:21
  • 1
    @eddyce while I disagree with the position that docker in docker (dind) is necessarily bad, this is not necessarily what OP is doing. if OP either binds the docker socket `-v /var/run/docker.sock` or exposes it `ENV DOCKER_HOST` then OP will be running docker out of docker (dood). dood is the recommended approach. – emory Jun 04 '18 at 19:49
  • @emory ok, invoking docker from inside a Dockerfile it's possible and doable: what for? – Edoardo Jun 05 '18 at 06:11
  • @eddyce i know nothing about lando except that it requires docker. Containerizing lando is a use case. – emory Jun 05 '18 at 10:19

1 Answers1

0

Lando has essentially 3 dependencies:

  1. Docker (Docker CE on Linux)
  2. Docker-Compose
  3. NodeJS (Typically the current LTS)

A container trying to run Lando itself should probably run from the [Docker][1] image, with all the typical "Docker in Docker" modifications and caveats such is possibly mounting the docker socket in the container, and running privileged mode, etc.

Your example is running from Lando's PHP FPM base image, which isn't at all designed to run either Docker or Node. It also isn't based on Ubuntu, but rather Debian directly (and you are including some Ubuntu specific code for installing Docker).

All that said, running Lando from within a Docker container is likely to run into issues with permissions and volume mounts among potential other things. It isn't recommended, though it might be possible.

Here is a Dockerfile from a small repo I made a few years back that worked to install an old version of Lando in a Dockerfile, it could help you make a more up to date one:

FROM ubuntu:bionic

RUN mkdir -p /root/.bin && touch /root/.zshrc

RUN apt update && apt upgrade -y && apt install -y \
  git \
  exuberant-ctags \
  neovim \
  python3-pip \
  software-properties-common \
  wget \
  zsh

RUN chsh -s $(which zsh)

RUN add-apt-repository ppa:martin-frost/thoughtbot-rcm \
  && apt update \
  && apt install rcm -y


RUN git clone https://github.com/thinktandem/dotfiles.git ~/dotfiles \
  && mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config} \
  && mkdir -p $XDG_CONFIG_HOME/nvim \
  && ln -s ~/.vim/autoload ~/.config/nvim/ \
  && ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim \
  && rcup 

RUN git clone https://github.com/nodenv/nodenv.git ~/.nodenv

RUN git clone \
  https://github.com/nodenv/node-build.git \
  /root/.nodenv/plugins/node-build

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
  && apt remove cmdtest \
  && apt update \
  && apt install --no-install-recommends yarn -y

RUN add-apt-repository ppa:cpick/hub \
  && apt update \
  && apt install -y hub

RUN apt remove docker docker-engine docker.io \
  && apt install -y \
  apt-transport-https \
  ca-certificates \
  curl \
  software-properties-common && \
  curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  | apt-key add - \
  && add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  bionic \
  stable" \
  && apt update \
  && apt install -y docker-ce

RUN TEMP_DEB="$(mktemp)" \
  && wget -O "$TEMP_DEB" \
  'https://github.com/lando/lando/releases/download/v3.0.0-rc.1/lando-    v3.0.0-rc.1.deb' \
  && dpkg -i "$TEMP_DEB" \
  && rm -f "$TEMP_DEB"
RUN curl -L git.io/antigen > ~/antigen.zsh
RUN RCRC=$HOME/dotfiles/rcrc rcup 
CMD ["/usr/bin/zsh"]