Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

326
Views
Run docker build in ubuntu:16.04 docker

I want to build a docker image in docker container.

So, I tried to create a docker-installed ubuntu docker image following https://docs.docker.com/engine/installation/linux/ubuntu/, but failed.

FROM ubuntu:16.04

RUN apt-get update && \ 
    apt-get install -y \
        apt-transport-https \
        ca-certificates \
        software-properties-common

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 && \
    apt-get install -y docker-ce

When I run docker images or other commands on the docker image created by above Dockerfile, the error happens.

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Is there any way to solve this problem? Thanks.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Besides the affect of AWS environment, the problem you have is caused by that you did not start docker daemon inside your container, as the error message shown.

Here's the steps to show how to make it work manually:

  1. Start and enter a container using the image built from your Dockerfile:

    docker run --privileged -it dind /bin/bash

And here is the problem you have:

root@82d6eab69331:/# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  1. Start docker daemon inside this container:

    root@82d6eab69331:~# /usr/bin/dockerd -H unix:///var/run/docker.sock > dockerd.log 2>&1 &

  2. Check log file to make sure it started correctly, and then try docker images:

    root@82d6eab69331:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE

So you may need to add entrypoint to start docker daemon in your Dockerfile. I test on environment of CentOS 7.2 and docker 1.12. Hope this could be helpful to you :-)

about 4 years ago · Santiago Trujillo Report

0

AWS CodeBuild doesn't "[..] allow customers to bring in their own Docker-in-Docker images [..]" yet.

We currently only support Docker-in-Docker (dind) with the official CodeBuild images

Source (Jan 12, 2017):

about 4 years ago · Santiago Trujillo Report

0

cannot connect to Docker daemon - you might need to run... Maybe, you can see the result this command.

$ sudo docker images

You should add your user in docker group. And then, you can use docker command without 'sudo'.

$ sudo usermod -aG docker ${USER}
$ sudo service docker restart

Next, you have to logout in your OS. Finally, when you login, you can use docker command without 'sudo'.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!