provider.docker: Error pinging Docker server: Got permission denied while trying to connect to the Docker daemon socket


provider.docker: Error pinging Docker server: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/_ping: dial unix /var/run/docker.sock: connect: permission denied

 

aryan@aryan-VirtualBox:~/docker$ terraform plan
Refreshing Terraform state in-memory prior to plan…
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
————————————————————————

Error: Error running plan: 1 error(s) occurred:

* provider.docker: Error pinging Docker server: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/_ping: dial unix /var/run/docker.sock: connect: permission denied
aryan@aryan-VirtualBox:~/docker$

try it with sudo command

aryan@aryan-VirtualBox:~/docker$ sudo terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

+ docker_image.image_id
id: <computed>
latest: <computed>
name: “ghost:latest”
Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only ‘yes’ will be accepted to approve.

Enter a value: yes

docker_image.image_id: Creating…
latest: “” => “<computed>”
name: “” => “ghost:latest”
docker_image.image_id: Still creating… (10s elapsed)
docker_image.image_id: Still creating… (20s elapsed)
docker_image.image_id: Creation complete after 20s (ID: sha256:f32905852788d222be7b05357a906cf9…2f50b7cea5a0ecf229d892d9d9ghost:latest)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
aryan@aryan-VirtualBox:~/docker$

To install Docker CE


sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce

aryan@aryan-VirtualBox:~$ sudo apt-get install
[sudo] password for aryan:
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
aryan@aryan-VirtualBox:~$ sudo apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> software-properties-common

aryan@aryan-VirtualBox:~$ sudo add-apt-repository \
> “deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable”
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:3 http://ca.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [6,426 B]

Reading package lists… Done
Building dependency tree
Reading state information… Done
ca-certificates is already the newest version (20180409).
software-properties-common is already the newest version (0.96.24.32.7).
The following additional packages will be installed:

Install Docker CE


Install Docker CE

Uninstall old versions:

sudo yum remove -y docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

Add the Utilities needed for Docker:

sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

Set up the stable repository:

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

Install Docker CE:

sudo yum -y install docker-ce

Enable and start Docker:

sudo systemctl start docker && sudo systemctl enable docker

Add cloud_user to the docker group:

sudo usermod -aG docker cloud_user

Steps to install terraform on Ubuntu / Ubuntu cloud server :


  1. Install unzip
    sudo apt-get install unzip
    
  2. Download latest version of the terraform
    wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
    
  3. Extract the downloaded file archive
    unzip terraform_0.11.13_linux_amd64.zip
    
  4. Move the executable into a directory searched for executables
    sudo mv terraform /usr/local/bin/
    
  5. Run it
    terraform --version

 

aryan@aryan-VirtualBox:~$ sudo apt-get install unzip
[sudo] password for aryan:
Reading package lists… Done
Building dependency tree
Reading state information… Done
unzip is already the newest version (6.0-21ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
aryan@aryan-VirtualBox:~$ wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
–2019-05-03 11:59:38– https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)… 151.101.1.183, 151.101.193.183, 151.101.129.183, …
Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.1.183|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 21128942 (20M) [application/zip]
Saving to: ‘terraform_0.11.13_linux_amd64.zip’

terraform_0.11.13_l 100%[===================>] 20.15M 69.3MB/s in 0.3s

2019-05-03 11:59:38 (69.3 MB/s) – ‘terraform_0.11.13_linux_amd64.zip’ saved [21128942/21128942]

aryan@aryan-VirtualBox:~$ unzip terraform_0.11.13_linux_amd64.zip
Archive: terraform_0.11.13_linux_amd64.zip
inflating: terraform
aryan@aryan-VirtualBox:~$ sudo mv terraform /usr/local/bin/
aryan@aryan-VirtualBox:~$ terraform –version
Terraform v0.11.13

A single instance application on an EC2 in AWS to Convert the application to operate on multiple servers


You run a single instance application on an EC2 instance in AWS. your architecture reams are looking to make changes and convert the application to operate on multiple servers. The app runs on Linux and currently access millions of flat file data file in the /data/… folder structure.

This database is stored on an EBS volume attached to the EC2 instance. How can this be moved to work on multiple servers with as little application changes as possible? What product would you suggest?

 

Answer: EFS

For this use-case, you should start looking at the new Amazon Elastic File System (EFS), which is designed to be multiply attached in exactly the way you are wanting. The key difference between EFS and EBS is that they provide different abstractions: EFS exposes the NFSv4 protocol, whereas EBS provides raw block IO access.