Last active
October 5, 2023 16:12
-
-
Save UbuntuEvangelist/f97b5cf81587be0bd803393e87fed493 to your computer and use it in GitHub Desktop.
Docker and Docker Compose Install Ubuntu 22.04 LTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
apt update -y | |
apt-get upgrade -y | |
dpkg-reconfigure tzdata | |
apt install build-essential checkinstall | |
apt install ubuntu-restricted-extras | |
apt install software-properties-common | |
apt upgrade -o APT::Get::Show-Upgraded=true | |
apt-show-versions | grep upgradeable | |
apt install apt-show-versions | |
apt update -y | |
apt-get upgrade -y | |
add-apt-repository ppa:nilarimogard/webupd8 | |
apt update -y | |
apt install launchpad-getkeys | |
launchpad-getkeys | |
add-apt-repository ppa:git-core/ppa | |
apt update -y | |
apt install git | |
git config --global user.name "masum" | |
git config --global user.email mail@domain.com | |
apt upgrade -y | |
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
cat /root/.ssh/id_rsa.pub | |
# add your KEY to github and gitlab SSH | |
####### Enable SSH ######## | |
apt-get install openssh-server | |
nano /etc/ssh/sshd_config | |
# Find (ctrl+w) this line and set | |
PermitRootLogin yes | |
PubkeyAuthentication yes | |
PasswordAuthentication yes | |
# Save & exit ctrl+s and ctrl+x then hit enter | |
service ssh restart | |
apt -f install | |
apt autoremove | |
apt -y autoclean | |
apt -y clean | |
apt update | |
reboot | |
# Docker Install | |
apt-get update -y | |
sudo apt-get update | |
sudo apt-get install ca-certificates curl gnupg | |
sudo install -m 0755 -d /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
sudo chmod a+r /etc/apt/keyrings/docker.gpg | |
echo \ | |
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
apt-get update -y | |
systemctl start docker | |
systemctl enable docker | |
usermod -aG docker ${USER} | |
systemctl restart docker | |
systemctl status docker | |
docker --version | |
# Docker Compose Install | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose | |
apt-get update -y | |
apt-get upgrade -y | |
docker compose --version | |
###########Docker Image Stop and Delete########################### | |
List all containers (only IDs) | |
$ docker ps -aq | |
Stop all running containers. | |
$ docker stop $(docker ps -aq) | |
Remove all containers. | |
$ docker rm $(docker ps -aq) | |
Remove all images. | |
$ docker rmi $(docker images -q) | |
How to remove docker and docker compose
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker restart $(docker ps -aq)
docker restart $(docker ps -a -q)