# Setup docker in ubuntu

Installation of docker, here we are assuming a Ubuntu machine.  
P.S. There is a bash script at the end that does all of this, you can just run that as well

Let us first remove existing docker files if any are present in the system

```bash
sudo apt-get remove docker docker-engine docker.io
```

Now let's update our packages before we go ahead

```bash
sudo apt-get update
```

Now we are going to install `docker.io` which is the Debian package for docker

```bash
sudo apt install docker.io
```

Depending on your machine's internet connection speed and other factors, this may take some time. After the installation is complete, you can run the command the following command to check if docker is running or not.

```bash
sudo docker ps -a
```

You might notice that you need to be a sudo to run this command, which can be a hindrance in the long run, so let's allow the user to run docker commands without using sudo, to do this run the following command

```bash
sudo usermod -aG docker $USER
```

replace `$USER` with your username, please ensure that the user should be a sudoer

---

Now to install docker-compose (If you are downloading docker on Mac or Windows, use dockerHub. It comes with docker compose bundled along with docker.

Download the latest stable release of the docker-compose standalone

```bash
curl -SL https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
```

This can change over time so get the current version from [`https://docs.docker.com/compose/install/standalone/`](https://docs.docker.com/compose/install/standalone/)

Once downloaded, give executable permissions to the binary

```bash
sudo chmod +x /usr/local/bin/docker-compose
```

This should be it, test whether docker-compose is installed by running the below command

```bash
docker-compose --version
```

If this doesn't work, try to create a symbolic link to `/usr/bin/`

```bash
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
```

and that is it, you have successfully installed docker & docker-compose to your Linux system, enjoy dockerizing stuff

## Bash Script

```bash
curl https://raw.githubusercontent.com/Kevin-Aaaquil/scripts/main/install_docker.sh -o install_docker.sh
```
