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 applyor- sudo netplan try(if unsure) hit- Enterwhen 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
- docker version| check docker version
- docker-comopose --version| check docker-compose version
- sudo usermod -aG docker USERNAME| To add user to docker group
- docker run hello-world| test if docker is working
- docker run --rm PACKAGE:latest| will run the latest version of a package- The - --rmmeans the container will automatically be removed when the container is exited
 
- docker run NAME| run the specific container- docker 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 container
- docker images| lists all local images on the host
- docker ps| lists all running containers- docker ps -a| will list all containers even running
 
- sudo chmod +x /usr/local/bin/docker-compose| allows you to run docker-compose
- docker-compose up| run docker docker-compose.yml file in current directory
- docker-compose down| stop docker docker-compose.yml file in current directory
Last updated