Docker Lab - jude-lindale/Wiki GitHub Wiki
Containerization with Docker
-
Set network adapter to sys265 LAN
-
sudo vi /etc/netplan/00-installer-config.yaml
network: ethernet: ens160: addresses: - <ip adress of machine> gateway4: <ip address of dateway> nameservers: addresses: <[addresse(s) of nameserver(s)/dns> version 2
- add a user
sudo adduser jude
- It prompts for all information give it a password
sudo usermod -aG sudo jude
vi /etc/hostname
- update cloud.cfg
- set-hostname docker01-jude
- Make sure to reboot the system
- Go add a A and PTR dns record.
- Disable remote root ssh
vi /etc/ssh/sshd_config
systemctl restart sshd
Install and Use Docker on Ubuntu 20.04
sudo apt update
sudo apt 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 focal stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
Executing Docker command without sudo
sudo usermod -aG docker ${USER}
su - ${USER}
id -nG
sudo usermod -aG docker username
Using the Docker command
- type docker and then double hit tab and then you see everything
- Ex.
docker run hello-world
Install and use Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
-docker run --rm archlinux:latest /bin/echo "hello sys265"
docker images
Docker Arch Linux Container
cat /etc/lsb-release
echo "Current Kernel is:$(uname -a)"
docker run -it archlinux /bin/unasme -a
docker run -d -P training/webapp python app.py
-docker ps
Docker Networking
- Add 32768 to the firewall
- Then go to docker01-jude:49153
docker ps
docker stop nervous higle
docker ps
Compose and WordPress
- mkdir wordpress
- cd into wordpress
- create file docker-compose.yml
- When all set run
docker-compose up -d
- Go to the browser and type in your docker01-jude:80
- And complete the setup
Basic Docker commands
docker ps
- basically you can see the services run and what port
- docker stop, start, rm, pause, they are all basic commands and basically do with how you say.
docker-compose up -d
, The -d shorthand stands for - -detach which is used to run a container in background and print container ID. the -P shorthand stands for - - publish-all which means publish all exposed ports to random ports