Getting Started with Artifactory Cloud
Using Docker repositories withArtifactory Cloudis quick and easy. With Artifactory Cloud, you are using Artifactory as a hosted service and there is no need to configure Artifactory with a reverse proxy.
The example at the end of this section shows a complete process of creating a Docker repository, logging in, pulling an image and pushing an image.
Using Docker Client with Artifactory Cloud
To use the Docker client with one of your Artifactory Cloud Docker repositories, you can use the native Docker client to login to each Docker repository, pull, and push images.
Log in to your repository use the following command with your Artifactory Cloud credentials.
docker login ${server-name}.jfrog.io
Pull an image using the following command.
docker pull ${server-name}.jfrog.io/{repo-name}/
Push an image by first tagging it and then using the push command.
docker tag
${server-name}.jfrog.io/{repo-name}/ docker push ${server-name}.jfrog.io/{repo-name}/
Test Your Setup
The following example demonstrates the following scenario:
- Pulling the
hello-world
Docker image - Logging into your virtual Docker repository
- Retagging the
hello-world
image, and then pushing it into your virtual Docker repository
In this example, the Artifactory Cloud server is namedacme.
- Start by creating avirtual Docker repositorycalled
dockerv2-virtual
. Pull the
hello-world
imagedocker pull hello-world
Log in to repository
dockerv2-virtual
docker login acme-dockerv2-virtual.jfrog.io
Tag the
hello-world
imagedocker tag hello-world acme-dockerv2-virtual.jfrog.io/hello-world
Push the tagged
hello-world
image todockerv2-virtual
docker push acme-dockerv2-virtual.jfrog.io/hello-world
Getting Started with Artifactory Pro On-Prem
The Docker client has the following two limitations:
- You cannot use a context path when providing the registry path (e.g
localhost:8082/artifactory
is not valid) - Docker will only send basic HTTP authentication when working against an HTTPS host or when using theinsecure registryflag
Artifactory offers solutions to these limitations allowing you to create and use any number of Docker registries.
- Using a reverse proxy
When used, a reverse proxy, maps Docker commands to one of the multiple Docker registries in Artifactory - Without a reverse proxy
从5.8版本,使用Docke Artifactory支持r without the use of a reverse proxy allowing you to create and use multiple Docker registries in Artifactory out-of-the-box.
Using a Reverse Proxy
When using Artifactory with a reverse proxy, you need to map Docker commands to Docker registries in Artifactory using either thesubdomain method,ports methodorrepository path method.
Testing or evaluating?
If you are currently only testing or evaluating using Artifactory with Docker, we recommendrunning Artifactory as a Docker containerwhich is easily installed and comes with a proxy server and Docker registries pre-configured out-of-the-box. You can be up and running in minutes.
With the ports method, a port number is mapped to each Artifactory Docker registry. While this is an easy way to get started, you will need to modify your reverse proxy configuration and add a new mapping for each new Docker registry you define in Artifactory. In addition, firewalls and other restrictions by your IT department may restrict port numbers making the ports method not feasible.
With the subdomain method, you only need to configure your reverse proxy once, and from then on, the mapping from Docker commands to Docker registries in Artifactory is dynamic and requires no further modification of your reverse proxy configuration.
The repository path method allows a single point of entry (URL) to access different repositories. This is done by embedding the name of the repository being accessed into the image path.
If a wildcard certificate is available, we recommend the subdomain method since it will only require a one time effort and follows Docker convention more closely.
The Subdomain Method
Getting started with Docker and your on-prem Artifactory Pro installation using the subdomain method involves four basic steps:
Configuring Artifactory
To configure Artifactory and your reverse proxy using the subdomain method, carry out the following steps:
- Make sure Artifactory isup and running, and isactivated with a valid license.
- Create yourvirtual Docker repository(as well as a local and remote Docker repository that it should aggregate). In our example below we will use a repository nameddocker-virtual.
- Make sure you have a reverse proxy server up and running.
Obtain awildcardSSL certificate or use a wildcard self-signed certificate. To create a self-signed certificate, you can followthese instructions for Ubuntu.
Make sure your certificate matches theArtifactory hostnameused in your reverse proxy configuration. In our example below we will useart.local.
Configuring Your Reverse Proxy
Artifactory's can generate your complete reverse proxy configuration file for supported servers.
Go toReverse Proxy Configuration Generatorand fill in the fields in according to how your reverse proxy is set up while making sure to:
- Use the correctArtifactory hostnamein thePublic Server Namefield (in our example this will be
art.local
) - SelectSubdomainas theReverse Proxy MethodunderDocker Reverse Proxy Settings.
Nginx
Copy the code snippet generated by theconfiguration generatorinto yourartifactory-nginx.conf
file, and place it in your/etc/nginx/sites-available
目录中。
Create the following symbolic link.
sudo ln -s /etc/nginx/sites-available/artifactory-nginx.conf /etc/nginx/sites-enabled/artifactory-nginx.conf
Apache HTTPD
Copy the code snippet generated by theconfiguration generatorinto yourartifactory-apache.conf
file and place it in your/etc/apache2/sites-available
目录中。
Create the following symbolic link:
sudo ln -s /etc/apache2/sites-available/artifactory-apache.conf /etc/apache2/sites-enabled/artifactory-apache.conf
Thehttpd . confheader file should be tuned to work correctly using these values to avoid errors:
# Apache libraries location (should be tuned) Define APACHE_LIB_DIR /usr/lib/apache2/modules <---- Input fied in UI could be great # Apache Logs (default : beside other Artifactory logs) Define APACHE_LOG_DIR /[TheArtifactoryHome]/logs <---- ErrorLog/CustomLog could be uncommented & Input fied in UI could be great LoadModule proxy_module ${APACHE_LIB_DIR}/mod_proxy.so LoadModule rewrite_module ${APACHE_LIB_DIR}/mod_rewrite.so LoadModule proxy_ajp_module ${APACHE_LIB_DIR}/mod_proxy_ajp.so LoadModule proxy_http_module ${APACHE_LIB_DIR}/mod_proxy_http.so LoadModule ssl_module ${APACHE_LIB_DIR}/mod_ssl.so <---- Only if HTTPS used Listen 443 <---- Only if HTTPS used Listen XXX <--- All port used as Docker registry
Configuring Your Docker Client
To configure your Docker client, carry out the following steps
Add the following to your DNS or to the client's
/etc/hosts
file:docker-virtual.art.local Since the certificate is self-signed, you need to import it to your Docker certificate trust store as described in theDocker documentation. Alternatively, you can configure the Docker client to work with an insecure registry as described in theDocker documentation.
Restart your Docker daemon/engine to apply the insecure registry flag (if self-signed certificate is imported, you do not need to restart the Docker daemon/engine).
Test Your Setup
To verify your reverse proxy is configured correctly, run the following command making sure that the return code is 200:
curl -I -k -v https:///api/system/ping
运行以下命令,以确保你的代理公司nfiguration is functional and can communicate with Artifactory:
Pull the "hello-world" image
docker pull hello-world
Login to repository docker-virtual
docker login docker-virtual.art.local
Tag the "hello-world" image
docker tag hello-world docker-virtual.art.local/hello-world
Push the tagged "hello-world" image to docker-virtual
docker push docker-virtual.art.local/hello-world
The Repository Path Method
Getting started with Docker and your on-prem Artifactory Pro installation using the path method involves four basic steps:
Configuring Artifactory
To configure Artifactory and your reverse proxy using the path method, carry out the following steps:
- Make sure Artifactory isup and running, and isactivated with a valid license.
- Create yourVirtual Docker Repositories(as well as a local and remote Docker repository that it should aggregate). In our example below we will use a repository nameddocker-virtual.
- Make sure you have a reverse proxy server up and running.
Obtain a valid SSL certificate or use a self-signed certificate. To create a self-signed certificate, you can followthese instructions for Ubuntu.
Make sure your certificate matches theArtifactory hostnameused in your reverse proxy configuration. In our example below we will useart.local.
Configuring your reverse proxy
Artifactory's can generate your complete reverse proxy configuration file for supported servers.
Go toReverse Proxy Configuration Generatorand fill in the fields in according to how your reverse proxy is set up while making sure to:
- Use the correctArtifactory hostnamein thePublic Server Namefield (in our example this will be
art.local
) - SelectRepository Pathas theReverse Proxy MethodunderDocker Reverse Proxy Settings.
Nginx
Copy the code snippet generated by theconfiguration generatorinto yourartifactory-nginx.conf
file, and place it in your/etc/nginx/sites-available
目录中。
Create the following symbolic link.
sudo ln -s /etc/nginx/sites-available/artifactory-nginx.conf /etc/nginx/sites-enabled/artifactory-nginx.conf
Apache HTTPD
Copy the code snippet generated by theconfiguration generatorinto yourartifactory-apache.conf
file and place it in your/etc/apache2/sites-available
目录中。
Create the following symbolic link:
sudo ln -s /etc/apache2/sites-available/artifactory-apache.conf /etc/apache2/sites-enabled/artifactory-apache.conf
Configuring Your Docker Client
To configure your Docker client, carry out the following steps
Add the following to your DNS or to the client's
/etc/hosts
file:art.local Since the certificate is self-signed, you need to import it to your Docker certificate trust store as described in theDocker documentation. Alternatively, you can configure the Docker client to work with an insecure registry as described in theDocker documentation.
Restart your Docker daemon/engine to apply the insecure registry flag (if self-signed certificate is imported, you do not need to restart the Docker daemon/engine).
Test Your Setup
To verify your reverse proxy is configured correctly, run the following command making sure that the return code is 200:
curl -I -k -v https:///api/system/ping
运行以下命令,以确保你的代理公司nfiguration is functional and can communicate with Artifactory:
Pull the "hello-world" image
docker pull hello-world
Login to repository docker-virtual
docker login art.local
Tag the "hello-world" image
docker tag hello-world art.local/docker-virtual/hello-world
Push the tagged "hello-world" image to docker-virtual
docker push art.local/docker-virtual/hello-world
端口的方法
Getting started with Docker and your on-prem Artifactory Pro installation using the ports method involves two basic steps:
Configuring Artifactory and Your Reverse Proxy
To configure Artifactory and your reverse proxy using the ports method, carry out the following steps:
- Make sure Artifactory isup and running, and is activated with a valid license.
- Create yourVirtual Docker Registry(as well as a local and remote Docker repository that it should aggregate). In our example below we will use a repository nameddocker-virtual.
- Make sure you have a reverse proxy server up and running.
Obtain an SSL certificate or use a Self-Signed certificate that can be generated following this example.
Make sure your certificate matches theArtifactory hostnameused in your reverse proxy configuration. In our example below we will use
art.local
.- Configure your reverse proxy. Artifactory'sReverse Proxy Configuration Generatorcan generate your complete reverse proxy configuration file for supported servers. All you need to do is fill in the fields in according to how your reverse proxy is set up while making sure to:
- Use the correctArtifactory hostnamein thePublic Server Namefield
- SelectPortsas theReverse Proxy MethodunderDocker Reverse Proxy Settings. In the example below, we will use port
5001
to bind repositorydocker-virtual
.
NGINX
For Artifactory to work with Docker, the preferred web server is
NGINX v1.3.9
and above.
First, you need to create a self-signed certificate for NGINXas described here for Ubuntu.
Then use Artifactory'sReverse Proxy Configuration Generatorto generate the configuration code snippet for you.
Copy the code snippet into yourartifactory-nginx.conf
file and place it in your/etc/nginx/sites-available
目录中。
Finally, create the following symbolic link:sudo ln -s /etc/nginx/sites-available/artifactory-nginx.conf /etc/nginx/sites-enabled/artifactory-nginx.conf
Apache HTTPDInstall Apache HTTP server as a reverse proxyand then install therequired modules.
Create the following symbolic link:
sudo ln -s /etc/apache2/mods-available/slotmem_shm.load /etc/apache2/mods-enabled/slotmem_shm.load
Similarly, create corresponding symbolic links for:
- headers
- proxy_balancer
- proxy_load
- proxy_http
- proxy_connect
- proxy_html
- rewrite.load
- ssl.load
- lbmethod_byrequests.load
Then use Artifactory'sReverse Proxy Configuration Generatorto generate the configuration code snippet for you.
Copy the code snippet into yourartifactory.conf
file and place it in your/etc/apache2/sites-available
目录中。HAProxy
First, you need to create a self-signed certificate for HAProxyas described here for Ubuntu.Then, copy the code snippet below into your
/etc/haproxy/haproxy.cfg
file. After editing the file as described in the snippet, you can test your configuration using the following command:haproxy -f /etc/haproxy/haproxy.cfg -c
Configuring Your Docker Client
To configure your Docker client, carry out the following steps
Add the following to your DNS or to the client's
/etc/hosts
file:art.local Since the certificate is self-signed, you need to import it to your Docker certificate trust store as described in theDocker documentation. Alternatively, you can configure the Docker client to work with an insecure registry by adding the following line to your
/etc/default/docker
file (you may need to create the file if it does not already exist):DOCKER_OPTS="$DOCKER_OPTS --insecure-registry art.local:5001"
Restart your Docker engine.
Test Your Setup
To verify your reverse proxy is configured correctly, run the following command:
// Make sure the following results in return code 200 curl -I -k -v https:///api/system/ping
运行以下命令,以确保你的代理公司nfiguration is functional and can communicate with Artifactory. In this example, we will pull down a Docker image, tag it and then deploy it to our ourdocker-virtual
repository that is bound toport 5001
:
// Pull the "hello-world" image docker pull hello-world // Login to repository docker-virtual docker login art-local:5001 // Tag the "hello-world" image docker tag hello-world art-local:5001/hello-world // Push the tagged "hello-world" image to docker-virtual docker push art-local:5001/hello-world
Testing With a Self-signed Certificate
Since the certificate is self-signed, you need to import it to your Docker certificate trust store as described in theDocker documentation. Alternatively, you can configure the Docker client to work with an insecure registry as described in theDocker documentation.
Restart your Docker daemon/engine to apply the insecure registry flag (if self-signed certificate is imported, you do not need to restart the Docker daemon/engine).
Running$docker info
will list the Insecure registries that have been applied under the Insecure Registries entry.- Use the steps above to interact with the Artifactory Docker Registry
Without a Reverse Proxy
Previously, Artifactory supported the Ports and Subdomain methods described above when using a reverse proxy. Fromversion 5.8.Artifactory introduces a new method referred to as the "Repository Path" method since it uses the the Docker repository path prefix (
) to access a specific Artifactory Docker registry from the Docker client. Note that you may still have a reverse proxy configured for Artifactory for other reasons, however when configured to use Repository Path method, requests to Docker registries in Artifactory will be handled by Artifactory's embedded Tomcat instead of the reverse proxy.
Docker API v2 required
You can only use the Repository Path method with Artifactory Docker registries configured for Docker API v2.
Sub-domain method is recommended for production
We recommend using theSub-domain methodfor Artifactory Docker registries in production systems because this method allows you to add wildcard SSL certificates on the reverse proxy for secure access to theDocker registry.
While you can add SSL certificates at the Tomcat level, this is not a recommended practice because the process of validation against the certificate is very resource intensive on memory and CPU.
The Repository Path method is more suitable when secure access is not required.
Configuring Artifactory
To configure Artifactory to use the Repository Path method, carry out the following steps:
Make sure Artifactory isup and running, and is activated with a valid license.
- Create yourvirtual Docker repository(as well as a local and remote Docker repository that it should aggregate). In our example below we will use a repository named
docker-virtual
. Go to theHTTP Settingspage from theAdministrationmodule underArtifactory | General | HTTP Settings.
In theDocker Settingspanel, selectRepository Pathas the Docker Access Method.
In theReverse Proxy Settingspanel selectEmbedded Tomcatas theServer Provider (which indicates you're not using a reverse proxy).You must use Embedded Tomcat
You can only use Artifactory as a Docker registry without a reverse proxy by using the internal embedded Tomcat.
Configuring Your Docker Client
Using the Repository Path method, you can work with Artifactory as a Docker registry without a reverse proxy on an insecure connection (i.e. only HTTP is supported, not HTTPS).您需要配置码头工人客户机with an insecure registryas described in theDocker documentation.
Restart your Docker daemon/engine to apply the insecure registry flag (if self-signed certificate is imported, you do not need to restart the Docker daemon/engine). Running$docker info
will list the Insecure registries that have been applied under the Insecure Registries entry.
Test Your Setup
Don't use localhost or 127.0.0.1 or "/artifactory"
Due to a limitation in the Docker client, you cannot access an Artifactory Docker registry as localhost or127.0.0.1.
If you need to access a local installation of Artifactory, make sure to specify its full IP address.
In addition, when specifying Artifactory's URL, you should omit the/artifactory
suffix normally used.
For example, if your local machine's IP address is 10.1.16.114, then you must specify your Artifactory URL ashttp://
10.1.16.114:8082
(usinghttp://localhost
:8082
will not work).
The code snippets below assume you have a virtual Docker repository nameddocker-virtual
in an Artifactory installation at IP 10.1.16.114.
First, you should verify that your Docker client can access Artifactory by run the following command. Making sure that the return code is 200:
curl -I -k -v http://10.1.16.114:8082/artifactory/api/system/ping
Now you can proceed to test your Docker registry.
Login to Artifactory as your Docker registry
docker login -u admin -p password 10.1.16.114:8082
Pull the
hello-world
image from thedocker-virtual
repositorydocker pull 10.1.16.114:8082/docker-virtual/hello-world:latest
Tag a Docker image
docker tag 10.1.16.114:8082/docker-virtual/hello-world:latest 10.1.16.114:8082/docker-virtual/
Push the tagged image to
docker-virtual
docker push 10.1.16.114:8082/docker-virtual/