# Know your Nexus docker repository url
ex: http://docker.box:8081/
# Know your Nexus connector port. Use the port that you specified in Nexus under "Create an HTTP connector at specified port. Normally used if the server is behind a secure proxy", ex: 8123. This is different than your main web interface Nexus port, ex: 8081.
# Know your non-admin login into Nexus
ex: mavenbuilds:secretpassword
# base64 the login:password string
echo "mavenbuilds:secretpassword" | base64
# copy this authentication string, ex: "ABc2394FL32iff20aeERL==" and use it in the next step
# create a new auths directive line using the following format:
echo -n '{"auths":{"docker.box:8123":{"auth":"ABc2394FL32iff20aeERL=="}}}' | base64
# save this string, and use it in the docker-secret.yaml file, we are naming this scret "docker-credentials" and placing it in namespace "app1"
apiVersion: v1
kind: Secret
metadata:
name: docker-credentials
namespace: app1
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: >
abc23oifaqerGIEOFSDLK3iseflISEflSEFLie324FLeEtc==
# create the docker secret
kubectl create -f docker-secret.yaml
# in your deployment.yaml file, specify the imagePullSecrets to use the secret from docker-credentials, ex:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app1test
namespace: app1
spec:
replicas: 1
selector:
matchLabels:
app: app1test
template:
metadata:
labels:
app: app1test
spec:
containers:
- name: app1test
image: docker.box:8123/helloworld
ports:
- containerPort: 8080
imagePullSecrets:
- name: docker-credentials
# To allow insecure connections from your docker client to your Nexus server (http instead of https), on the docker client, run:
sudo nano /etc/docker/daemon.json
# and add the Nexus repo location, use the port that you specified in Nexus under "Create an HTTP connector at specified port. Normally used if the server is behind a secure proxy", ex: 8123. This is different than your main web interface Nexus port, ex: 8081.
{
"insecure-registries": ["docker.box:8123"]
}
# and restart docker
sudo systemctl restart docker
# then try to log in
docker login docker.box:8123