Wednesday, August 16, 2023

Removing Docker container

 

Removing Docker container


To delete the container named "kke-container" running on Server , you can use the following steps:

1. Stop and Remove Container:

To delete the container named "kke-container," you need to stop and then remove the container. Use the following commands:

  # docker stop kke-container

  Remove the container: 

  # docker rm kke-container

   

The first command stops the container, and the second command removes it.


2. Verify Container Deletion:

      You can verify that the container has been removed by listing all containers on the server using:

#   docker ps -a

   If the "kke-container" is no longer listed, it has been successfully deleted.


That's it! The container named "kke-container" has been deleted from  Server . 

Running a Docker container

 

Running a Docker container 

To create and run an Nginx container named "nginx_2" using the "nginx" image with the "alpine" tag on Server, follow these steps:


1. Pull and Run Nginx Container:

   Use the following command to create and run the "nginx_2" container using the specified image and tag:

#   docker run -d --name nginx_2 nginx:alpine

  

   - `-d`: Run the container in the background (detached mode).

   - `--name nginx_2`: Assign the name "nginx_2" to the container.

   - `nginx:alpine`: Use the "nginx" image with the "alpine" tag.


2. Verify Container Status:

   To verify that the container is running, you can use the following command:

  #  docker ps

   This command will display a list of running containers, including their names, IDs, and other information. You should see the "nginx_2" container listed if it's running successfully.


That's it! You've created and run the Nginx container named "nginx_2" on Server  using the specified image and tag. 

Checking Docker and Docker Compose services are running


Checking Docker and Docker Compose services are running 


To check if Docker and Docker Compose services are running on your system, you can use the following commands:


1. Check Docker Service:

   To check the status of the Docker service, use the following command:

 #   sudo systemctl status docker


   This command will display information about the Docker service, including its current status (running or stopped), recent logs, and more.

   If the service is not running, you can start it using:

  # sudo systemctl start docker

   And enable it to start at boot:

  #  sudo systemctl enable docker


2. Check Docker Compose:

   To check the availability of Docker Compose, you can use:

#   docker-compose --version

    If the command outputs the version of Docker Compose, then it is installed and accessible.

If you encounter any issues or receive error messages while checking the services, please provide more details about the errors, and I'll be happy to help you troubleshoot.

Docker Compose Installation

 Docker Compose Installation 

Let's go through the installation process for Docker Compose:


1. Install Docker Compose:

 # sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

 # sudo chmod +x /usr/local/bin/docker-compose


2. Verify Installation:

   After running the installation commands, verify that Docker Compose is installed and accessible:

#   docker-compose --version


If you're still encountering the "command not found" error, it's possible that the installation didn't complete successfully. Make sure that the installation commands are executed with proper administrative privileges (using `sudo`).


If you continue to face issues, please provide more details about the steps you've taken and any error messages you encounter, and I'll be glad to assist you further.

Docker Installation - Errors related to importing the "which" module

 Docker Installation - Errors

In case  you encountered errors related to importing the "which" module while installing Docker CE on CentOS Stream 8. The "which" module is often used to find the location of an executable on the system. These errors could be caused by various reasons, including missing dependencies or issues with your system's Python environment.

To resolve this, you can take the following steps:

1. Install Python3:

   Ensure that you have Python3 installed on your system. If it's not installed, you can install it using the following command:

#   sudo dnf install python3


2. Verify Python3 Installation:

   Confirm that Python3 is properly installed by running:

   # python3 --version

   This should display the version of Python3 installed on your system.


3. Reattempt Docker CE Installation:

   After confirming Python3 is installed, try reattempting the Docker CE installation:

  # sudo dnf install docker-ce


4. Start Docker Service:

   Once Docker CE is installed, start the Docker service as previously described:

   # sudo systemctl start docker

   # sudo systemctl enable docker

   

5. Verify Installation:

   Verify the Docker and Docker Compose installation as described earlier:

   # docker --version

   # docker-compose --version

  

If you continue to encounter issues, ensure that your system's environment is stable, and that you have necessary dependencies installed. You might also consider checking for any updates or patches related to the specific issue you're facing.

Docker Installation

 

To install Docker CE and Docker Compose on CentOS Stream release 8 and start the Docker service, follow these steps:


1. Update Packages:

   Ensure your system is up-to-date by running the following command:

#   sudo dnf update


2. Install Docker CE:

   Install Docker Community Edition (CE) using the following commands:

 #  sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

 #  sudo dnf install docker-ce


3. Install Docker Compose:

   Install Docker Compose using the following commands:

  # sudo dnf install -y curl

  # sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

  # sudo chmod +x /usr/local/bin/docker-compose


4. Start Docker Service:

   Start and enable the Docker service:

#   sudo systemctl start docker

#  sudo systemctl enable docker

  

5. Verify Installation:

   Check the Docker version to confirm the installation:

#   docker --version

   Check the Docker Compose version:

 #  docker-compose --version


Your Server  should now have Docker CE and Docker Compose installed and the Docker service running.


Tuesday, August 8, 2023

Docker Troubleshooting

 

Docker Troubleshooting 


To troubleshoot and resolve the issue with the static website running within the container in App Server 


1.  Check Container Status: 

      command:

     # docker ps -a


2.  Inspect Container Logs: 

   Check the container logs for any error messages or issues:

   # docker logs nautilus

  

3. Confirm Port Mapping:

Verify that the port mapping is set up correctly to map host port 8080 to container port 80. 

You can check this when running the container:

#  docker run -d -p 8080:80 --name nautilus -v /var/www/html:/usr/local/apache2/htdocs <image_name>

 # docker exec -it nautilus curl http://localhost:80/


4. Check Website from Host:

   Run the `curl` command from Server itself to check if the website is accessible from the host:

   curl http://localhost:8080/


5. Inspect Apache Configuration: 

If there are still issues, check the Apache configuration files inside the container 

(`/usr/local/apache2/conf/httpd.conf`) for any misconfigurations.


6. Check Firewall Rules:

 Ensure that any firewall rules on Server are not blocking incoming traffic on port 8080.


7. Container Restart:

  If all else fails, try stopping and then restarting the container:

   # docker stop nautilus

   # docker start nautilus


By following these steps, you should be able to identify and resolve the issues with the static website running in the  container on  Server.

Removing Docker container

  Removing Docker container To delete the container named "kke-container" running on Server , you can use the following steps: 1. ...