Changes between Version 5 and Version 6 of dockerdeployment2023
- Timestamp:
- Dec 4, 2023, 4:25:34 AM (12 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
dockerdeployment2023
v5 v6 1 1 === Part 1: === 2 Installing Docker on Ubuntu Server 2 3 '''Installing Docker on Ubuntu Server''' 3 4 4 5 1. Update Your System: Ensure your system package database is up-to-date. 5 6 6 ` $sudo apt update `7 8 ` $sudo apt upgrade`7 ` sudo apt update ` 8 9 `sudo apt upgrade` 9 10 10 11 2. Install Docker: Install Docker using the convenience script provided by Docker. 11 12 12 ` $curl -fsSL https://get.docker.com -o get-docker.sh`13 14 ` $sudo sh get-docker.sh`13 ` curl -fsSL https://get.docker.com -o get-docker.sh` 14 15 ` sudo sh get-docker.sh` 15 16 16 17 3. Add User to Docker Group (Optional): If you want to run Docker commands without sudo, add your user to the docker group. 17 18 18 ` $sudo usermod -aG docker ${USER}`19 ` sudo usermod -aG docker ${USER}` 19 20 20 21 Log out and log back in for the group changes to take effect. … … 22 23 4. Start and Enable Docker: Ensure Docker starts on boot. 23 24 24 ` $sudo systemctl enable docker`25 26 ` $sudo systemctl start docker`25 ` sudo systemctl enable docker` 26 27 ` sudo systemctl start docker` 27 28 28 29 5. Verify Docker Installation: Check the Docker version to ensure it's installed correctly. 29 30 30 ` $docker --version`31 32 === 6. Deploying a Sample Web Application using Docker === 31 ` docker --version` 32 33 6. Deploying a Sample Web Application using Docker 33 34 34 35 6.1 Pull a Sample Web Application Image: For this guide, we'll use a simple HTTP server image from Docker Hub. 35 36 36 ` $docker pull httpd`37 ` docker pull httpd` 37 38 38 39 6.2 Run the Web Application: Start a container using the httpd image. This will run the web server on port 8080. 39 40 40 ` $docker run -d -p 8080:80 --name sample-webapp httpd`41 ` docker run -d -p 8080:80 --name sample-webapp httpd` 41 42 42 43 6.3 Access the Web Application: If you're accessing the server locally, open a web browser and navigate to: (Since you are connected via SSH lets install a text-based web browser lynx.) 43 44 44 ` $sudo apt-get install lynx`45 46 ` $lynx http://localhost:8080`45 ` sudo apt-get install lynx` 46 47 ` lynx http://localhost:8080` 47 48 48 49 6.4 Stop and Remove the Web Application (Optional): 49 50 When you're done testing the web application, you can stop and remove the container. 50 51 51 ` $docker stop sample-webapp`52 53 ` $docker rm sample-webapp`52 ` docker stop sample-webapp` 53 54 ` docker rm sample-webapp` 54 55 55 56 Extra Ref: 56 57 57 https://linuxhint.com/best_linux_text_based_browsers/ 58 https://romanzolotarev.com/ssh.html 59 60 Basic Docker Commands and Their Usage 58 [https://linuxhint.com/best_linux_text_based_browsers/][] 59 [https://romanzolotarev.com/ssh.html] 60 61 ==== Basic Docker Commands and Their Usage ==== 61 62 62 63 • ` docker --version` … … 64 65 Example: `docker --version` 65 66 66 • `docker inf `o67 • `docker info` 67 68 Usage: Provides detailed information about the Docker installation. 68 69 Example:` docker info` … … 108 109 Example: `docker logs my_container` 109 110 110 Troubleshooting Common Docker Container Issues 111 === Troubleshooting Common Docker Container Issues === 111 112 112 113 • Container Fails to Start 113 114 114 Check Logs: Use docker logs <container_name> to check for any error messages. 115 Inspect Configuration: Ensure that the Docker run command has the correct parameters, such as port mappings and volume mounts. 115 Check Logs: Use `docker logs <container_name>` to check for any error messages. 116 117 Inspect Configuration: Ensure that the Docker run command has the correct parameters, such as port mappings and volume mounts. 116 118 117 119 • Networking Issues 118 120 119 Check IP Address: Use docker inspect <container_name> | grep IPAddress to find the container's IP address. 121 Check IP Address: Use `docker inspect <container_name> | grep IPAddress` to find the container's IP address. 122 120 123 Check Port Bindings: Ensure that the ports inside the container are correctly mapped to the host using the -p option. 121 You may use docker port <container_name>to further check the port mapping.124 You may use `docker port <container_name>` to further check the port mapping. 122 125 123 126 • File or Directory Not Found in Container