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 addrEdit the file
/etc/netplan/00-installer-config.yamlEdit 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 applyorsudo netplan try(if unsure) hitEnterwhen prompted
Making A New Sudo User
Make a new user with a user directory
useradd -m USERNAMEMake this account an admin
sudo usermod -aG sudo USERNAME
Docker Commands
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 packageThe
--rmmeans the container will automatically be removed when the container is exited
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
Last updated