Install Artifactory using Docker

JFrog Installation & Setup Documentation

Content Type
Installation & Setup

Installing Artifactory with Docker involves running Artifactory within a container, providing a highly portable and consistent deployment. This method is suitable for both single-node setups and high-availability (HA) configurations.

Here you'll find step-by-step instructions for installing JFrog Artifactory using Docker commands, covering both single-node and high-availability (HA) configurations.

Prerequisites

Install Artifactory Docker Containers

Throughout these installation steps, you must have sudo privileges or be the root user for system-level operations, package installations, and file modifications. This ensures that Artifactory can be installed correctly.

The following steps cover the installation process for both single-node and HA:

  1. Set JFROG_HOME Variable and Create Directories

    1. Set the JFROG_HOME directory:

      Run the following command to define the JFROG_HOME environment variable, pointing to the base directory where Artifactory's data (var folder) will reside on the host machine.

      export JFROG_HOME=<path of your directory>

      For example: export JFROG_HOME=/opt/jfrog. For more information, see JFrog Product Directory Structure.

    2. Create system.yaml and Set Permissions:

      In your defined JFROG_HOME directory, create the necessary Artifactory directory structure, including an empty system.yaml file, and set the required ownership. The user creating the folder should be the user running the Docker command.

      mkdir -p $JFROG_HOME/artifactory/var/etc/
      cd $JFROG_HOME/artifactory/var/etc/
      touch ./system.yaml
      sudo chown -R 1030:1030 $JFROG_HOME/artifactory/var

      If you are using Docker on a Mac machine, run the following additional command to ensure proper permissions:

      sudo chmod -R 777 $JFROG_HOME/artifactory/var
  2. Set up Artifactory Database

    Artifactory requires an external database for production. JFrog highly recommends using PostgreSQL for all products in the JFrog Platform, although Artifactory supports additional databases. For more information, see Database Configuration.

    1. For Non-Production (Optional: PostgreSQL Container):

      For a non-production environment, you can start a PostgreSQL container on the same machine as your Artifactory container:

      docker run --name postgres -itd -e POSTGRES_USER=artifactory -e POSTGRES_PASSWORD=password -e POSTGRES_DB=artifactorydb -p 5432:5432 library/postgres:<version>
      # Example:
      # docker run --name postgres -itd -e POSTGRES_USER=artifactory -e POSTGRES_PASSWORD=password -e POSTGRES_DB=artifactorydb -p 5432:5432 library/postgres:16.8
    2. For Production (External Database) and Configuration:

      For production environments, connect to an external database. On each Artifactory node, configure the system.yaml file with the database configuration details.

      shared:
        database:
          driver: org.postgresql.Driver
          type: postgresql
          url: jdbc:postgresql://host.docker.internal:5432/artifactorydb
          username: artifactory
          password: password

      The database connection URL may vary depending on the Container Engine in use (for example, host.docker.internal for Docker Desktop, actual IP for remote DB or Docker on Linux). Please ensure you are using the correct URL for your specific environment.

    3. Configure Other Supported Databases (Optional):

      To utilize databases other than PostgreSQL, you'll need to set shared.database.allowNonPostgresql to true in your system.yaml and configure the database details. Here's an example for MySQL:

      shared:
        database:
          allowNonPostgresql: true
          type: mysql
          driver: com.mysql.jdbc.Driver
          url: jdbc:mysql://<your db url, for example: localhost:3306>/artdb?characterEncoding=UTF-8&elideSetAutoCommits=true&useSSL=false
          username: artifactory
          password: password

    For more information about creating and configuring databases, see Set up Database.

  3. Configure Host ID and IP for Container Installations:

    For Podman and other Container Installations, verify that the host's ID (shared.node.id) and IP (shared.node.ip) are explicitly added to the system.yaml. If these are not manually added, they are automatically resolved as the container's IP, meaning other nodes and services will not be able to reach this instance.

    shared:
      node:
        ip: host-ip # Actual IP of the host machine
        id: host-id
  4. Set up Supported Filestores

    The filestore is where Artifactory physically stores the binaries.

    • Single-Node: A local filesystem is the default, but externalizing it (for example, to a dedicated volume) is recommended for easier management and potential migration.

    • High Availability (HA): A shared filestore is mandatory. This can be NFS, S3, Azure Blob Storage, Google Cloud Storage, or another supported object storage solution. All Artifactory nodes in the cluster must have unified and reliable network access to this single shared filestore.

    For more information about configuring filestores, see Set up Filestore.

  5. Configure HA (On Each Artifactory Node)

    For HA installations, you'll ensure that the Artifactory configuration reflects its role in a cluster. A High Availability (HA) installation typically requires at least three or more nodes.

    1. Configure system.yaml for HA

      Edit $JFROG_HOME/artifactory/var/etc/system.yaml on each node.

      • In the node section, set haEnabled to true.

      • taskAffinity set to any indicates that all the nodes in the HA can act as primary nodes.

      shared:
        node:
          haEnabled: true
          taskAffinity: any
      
    2. Ensure the database section (as configured in Step 2 is also present and identical on all nodes.

  6. Start First Artifactory Node (for Single-Node and HA)

    Note

    For High Availability installations, it is crucial to ensure the first Artifactory node is fully up and running, and its generated masterKey is copied to all other nodes before starting any subsequent Artifactory services. Failure to do so will prevent the cluster from forming correctly and lead to startup failures.

    Run the following command to start the Artifactory service. On the first HA node, Artifactory will initialize the database and potentially generate the master.key if it doesn't already exist.

    docker run --name artifactory_1 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8081:8081 -p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:<version>
    # Example:
    # docker run --name artifactory_1 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8081:8081 -p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:7.111.11
    • For Artifactory Open Source, replace artifactory-pro with artifactory-oss.

    • For Artifactory Community Edition for C/C++, replace artifactory-pro with artifactory-cpp-ce.

    For HA setup,

    1. Add the License:

      Once the first Artifactory node (for example, artifactory_1) is fully up and running, add the license through its UI.

    2. Copy master.key to Other Nodes:

      Copy the master.key file from $JFROG_HOME/artifactory/var/etc/security/ of the first node to the identical path on all other nodes.

    3. Start Remaining Nodes for HA:

      Once the masterKey is synchronized across all nodes, start the Artifactory service on the remaining nodes:

      # Start the second node:
      docker run --name artifactory_2 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8083:8081 -p 8084:8082 releases-docker.jfrog.io/jfrog/artifactory-<pro|oss|cpp-ce>:<version>
      # Example:
      # docker run --name artifactory_2 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8083:8081 -p 8084:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:7.111.11
      
      # Start the third node (if applicable):
      docker run --name artifactory_3 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8085:8081 -p 8086:8082 releases-docker.jfrog.io/jfrog/artifactory-<pro|oss|cpp-ce>:<version>
      # Example:
      # docker run --name artifactory_3 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8085:8081 -p 8086:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:7.111.11
      
  7. Monitor Artifactory

    To manage Artifactory using native Docker commands:

    • List running containers:

      docker ps
    • Stop Artifactory container (replace artifactory with your container name, for example, artifactory_1):

      docker stop artifactory
    • Check Artifactory logs:

      docker logs -f artifactory
  8. Access Artifactory UI

    After starting Artifactory, open your browser and go to http://<SERVER_HOSTNAME>:8082/, replacing <SERVER_HOSTNAME> with your server's actual IP address or hostname.

    For HA setup, you will typically access Artifactory through a load balancer that distributes traffic across your HA nodes. Configure your load balancer to direct traffic to http://< ARTIFACTORY_NODE_IP>:8082/ on each node.

  9. Initial Setup

    Upon first access, you'll be guided through an onboarding wizard:

    • Change Default Admin Password: The default credentials are admin/password. Change this immediately.

    • Configure Base URL: Configure the Base URL.

    • Apply Licenses: If you have an Artifactory Pro or Enterprise license, apply it.