Lab 2.0: Docker
Summary
This lab was extremely useful for me because I have tried to install Docker before on a fedora server and didn’t understand anything at all. So being able to go over it and actually have well formatted steps I can now say I can understand somewhat how to use Docker and Docker-Compose.
Ubuntu Network Configuration
- Get network adapter name by using
ip addr
- Edit the file
/etc/netplan/00-installer-config.yaml
- Edit the file to look like below without ()
network:
version: 2
renderer: networkd
ethernets:
(**adapter name**):
addresses: [(**ip**)/(**subnet**)]
gateway4: gateway
nameservers:
addresses: [(**dns server ip**)]
- now run
sudo netplan apply
orsudo netplan try
(if unsure) hitEnter
when prompted
Making A New Sudo User
- Make a new user with a user directory
useradd -m USERNAME
- Make this account an admin
sudo usermod -aG sudo USERNAME
Docker Commands (Outdated 03-20-24)
docker version
| check docker versiondocker-comopose --version
| check docker-compose versionsudo usermod -aG docker USERNAME
| To add user to docker groupdocker run hello-world
| test if docker is workingdocker run --rm PACKAGE:latest
| will run the latest version of a package- The
--rm
means the container will automatically be removed when the container is exited
- The
docker run NAME
| run the specific containerdocker run -d -P
| will run container | -d (—detach) means run container in the background and print container ID | -P (–publish-all) means Publish all exposed ports to random ports
docker stop NAME
| stop the specific containerdocker images
| lists all local images on the hostdocker ps
| lists all running containersdocker ps -a
| will list all containers even running
sudo chmod +x /usr/local/bin/docker-compose
| allows you to run docker-composedocker-compose up
| run docker docker-compose.yml file in current directorydocker-compose down
| stop docker docker-compose.yml file in current directory