Deploy Nexus as a Docker Container

574n13y

Vivesh

Posted on November 22, 2024

Deploy Nexus as a Docker Container

Project Title:

Deploy Nexus as a Docker Container


Technologies Used:

  • Docker: Containerization platform to run Nexus.
  • Nexus Repository Manager: Artifact repository for DevOps.
  • DigitalOcean: Cloud provider to host the droplet.
  • Linux: Operating system for the droplet.

Project Description:

  1. Create and Configure Droplet: Set up a DigitalOcean droplet with Linux to serve as the hosting environment for Nexus.
  2. Set Up and Run Nexus: Use Docker to deploy Nexus on the droplet. Ensure Nexus is configured to manage artifacts securely and efficiently.

Step-by-Step Implementation:

1. Create and Configure Droplet

  1. Log in to the DigitalOcean Console.
  2. Create a new droplet:
    • Choose an image: Ubuntu 22.04 or another Linux distribution.
    • Select a plan: At least 2 GB RAM for Nexus to run smoothly.
    • Add SSH keys for secure access or use a password-based approach.
    • Launch the droplet and note down its public IP.
  3. Access the droplet using SSH:
   ssh root@<your-droplet-ip>
Enter fullscreen mode Exit fullscreen mode
  1. Update the system:
   sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

2. Install Docker on the Droplet

  1. Install prerequisites:
   sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
Enter fullscreen mode Exit fullscreen mode
  1. Add Docker's GPG key and repository:
   curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Enter fullscreen mode Exit fullscreen mode
  1. Install Docker:
   sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io
Enter fullscreen mode Exit fullscreen mode
  1. Verify Docker installation:
   docker --version
Enter fullscreen mode Exit fullscreen mode

3. Run Nexus as a Docker Container

  1. Pull the Nexus Docker image:
   docker pull sonatype/nexus3
Enter fullscreen mode Exit fullscreen mode
  1. Create a directory for persistent data:
   mkdir -p /opt/nexus-data
   chmod -R 200 /opt/nexus-data
Enter fullscreen mode Exit fullscreen mode
  1. Run the Nexus container:
   docker run -d -p 8081:8081 --name nexus -v /opt/nexus-data:/nexus-data sonatype/nexus3
Enter fullscreen mode Exit fullscreen mode
  1. Confirm the container is running:
   docker ps
Enter fullscreen mode Exit fullscreen mode
  1. Access Nexus:

    • Open a browser and navigate to http://<your-droplet-ip>:8081.
    • Log in with the default credentials:
      • Username: admin
      • Password: Retrieved from /nexus-data/admin.password inside the container:
       docker exec nexus cat /nexus-data/admin.password
    

Post-Deployment Steps:

  • Secure Nexus:
    • Update the admin password.
    • Configure HTTPS using a reverse proxy (e.g., Nginx).
  • Enable Nexus Features:
    • Set up repositories for Maven, npm, or Docker images.

Click here for repo - https://gitlab.com/574n13y/devops4-deploy-nexus-as-docker-container

Happy Learning !!!

💖 💪 🙅 🚩
574n13y
Vivesh

Posted on November 22, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Deploy Nexus as a Docker Container
docker Deploy Nexus as a Docker Container

November 22, 2024