Changes between Version 3 and Version 4 of dockerdeployment2023


Ignore:
Timestamp:
Nov 28, 2023, 5:07:01 AM (12 months ago)
Author:
deepthi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • dockerdeployment2023

    v3 v4  
    441. Update Your System: Ensure your system package database is up-to-date.
    55
    6 $ sudo apt update
    7 $ sudo apt upgrade
     6`$ sudo apt update `
     7
     8`$ sudo apt upgrade`
    89
    9102. Install Docker: Install Docker using the convenience script provided by Docker.
    1011
    11 $ curl -fsSL https://get.docker.com -o get-docker.sh
    12 $ sudo sh get-docker.sh
     12`$ curl -fsSL https://get.docker.com -o get-docker.sh`
     13
     14`$ sudo sh get-docker.sh`
    1315
    14163. Add User to Docker Group (Optional): If you want to run Docker commands without sudo, add your user to the docker group.
    1517
    16 $ sudo usermod -aG docker ${USER}
     18`$ sudo usermod -aG docker ${USER}`
    1719
    1820Log out and log back in for the group changes to take effect.
     
    20224. Start and Enable Docker: Ensure Docker starts on boot.
    2123
    22 $ sudo systemctl enable docker
    23 $ sudo systemctl start docker
     24`$ sudo systemctl enable docker`
     25
     26`$ sudo systemctl start docker`
    2427
    25285. Verify Docker Installation: Check the Docker version to ensure it's installed correctly.
    2629
    27 $ docker --version
     30`$ docker --version`
    2831
    2932=== 6. Deploying a Sample Web Application using Docker ===
     
    31346.1 Pull a Sample Web Application Image: For this guide, we'll use a simple HTTP server image from Docker Hub.
    3235
    33 $ docker pull httpd
     36`$ docker pull httpd`
    3437
    35386.2 Run the Web Application: Start a container using the httpd image. This will run the web server on port 8080.
    3639
    37 $ docker run -d -p 8080:80 --name sample-webapp httpd
     40`$ docker run -d -p 8080:80 --name sample-webapp httpd`
    3841
    39426.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.)
    4043
    41 $ sudo apt-get install lynx
    42 $ lynx http://localhost:8080
     44`$ sudo apt-get install lynx`
     45
     46`$ lynx http://localhost:8080`
    4347
    44486.4 Stop and Remove the Web Application (Optional):
    4549When you're done testing the web application, you can stop and remove the container.
    4650
    47 $ docker stop sample-webapp
    48 $ docker rm sample-webapp
     51`$ docker stop sample-webapp`
     52
     53`$ docker rm sample-webapp`
    4954 
    5055Extra Ref:
     
    5560Basic Docker Commands and Their Usage
    5661
    57 •           docker --version
     62•          ` docker --version`
    5863        Usage: Displays the Docker version installed.
    59         Example: docker --version
    60 
    61 •           docker info
     64        Example: `docker --version`
     65
     66•           `docker inf`o
    6267        Usage: Provides detailed information about the Docker installation.
    63         Example: docker info
    64 
    65 •           docker pull <image_name>
     68        Example:` docker info`
     69
     70•           `docker pull <image_name>`
    6671        Usage: Downloads a Docker image from Docker Hub.
    67         Example: docker pull nginx
    68 
    69 •           docker build -t <image_name>:<tag> <path>
     72        Example: `docker pull nginx`
     73
     74•           `docker build -t <image_name>:<tag> <path>`
    7075        Usage: Builds a Docker image from a Dockerfile located at <path>.
    7176        Example: docker build -t myapp:latest .
    7277
    73 •           docker images
     78•          ` docker images`
    7479        Usage: Lists all available Docker images on the system.
    75         Example: docker images
    76 
    77 •           docker run <options> <image_name>
     80        Example:` docker images`
     81
     82•           `docker run <options> <image_name>`
    7883        Usage: Creates and starts a container from a Docker image.
    79         Example: docker run -d -p 80:80 nginx
    80 
    81 •           docker ps
     84        Example: `docker run -d -p 80:80 nginx`
     85
     86•           `docker ps`
    8287        Usage: Lists running containers.
    83         Example: docker ps
    84 
    85 •           docker ps -a
     88        Example:` docker ps`
     89
     90•          ` docker ps -a`
    8691        Usage: Lists all containers, including stopped ones.
    87         Example: docker ps -a
    88 
    89 •           docker stop <container_id/container_name>
     92        Example: `docker ps -a`
     93
     94•           `docker stop <container_id/container_name>`
    9095        Usage: Stops a running container.
    91         Example: docker stop my_container
    92 
    93 •           docker rm <container_id/container_name>
     96        Example: `docker stop my_container`
     97
     98•           `docker rm <container_id/container_name>`
    9499        Usage: Removes a stopped container.
    95         Example: docker rm my_container
    96 
    97 •           docker rmi <image_name>
     100        Example: `docker rm my_container`
     101
     102•          ` docker rmi <image_name>`
    98103        Usage: Removes a Docker image.
    99         Example: docker rmi nginx
    100 
    101 •           docker logs <container_id/container_name>
     104        Example: `docker rmi nginx`
     105
     106•           `docker logs <container_id/container_name>`
    102107        Usage: Displays logs from a running or stopped container.
    103         Example: docker logs my_container
     108        Example: `docker logs my_container`
    104109 
    105110Troubleshooting Common Docker Container Issues