@Override public void init() { super.init(); ConfigToAttributes.apply(this, DOCKER_HOST); ConfigToAttributes.apply(this, DOCKER_REGISTRY_PORT); DockerHost host = (DockerHost) sensors().get(DOCKER_HOST); String installDir = host.sensors().get(SoftwareProcess.INSTALL_DIR); SshMachineLocation sshMachine = host.getDynamicLocation().getMachine(); String sshMachineInstallDir = getSSHMachineInstallDir(); config() .set( DockerAttributes.DOCKER_PORT_BINDINGS, MutableMap.of(sensors().get(DOCKER_REGISTRY_PORT), 5000)); config() .set( DockerAttributes.DOCKER_HOST_VOLUME_MAPPING, MutableMap.of(Os.mergePaths(installDir, "certs"), "/certs")); sshMachine.installTo( ImmutableMap.of(SshTool.PROP_PERMISSIONS.getName(), "0755"), SCRIPT_LOCATION, Os.mergePaths(sshMachineInstallDir, CREATE_CERTS_SCRIPT_NAME)); sshMachine.installTo( config().get(DockerInfrastructure.DOCKER_CA_CERTIFICATE_PATH), Os.mergePaths(sshMachineInstallDir, "ca-cert.pem")); sshMachine.installTo( config().get(DockerInfrastructure.DOCKER_CA_KEY_PATH), Os.mergePaths(sshMachineInstallDir, "ca-key.pem")); int result = sshMachine.execCommands( "installCerts", ImmutableList.of( BashCommands.sudo( String.format( "%s %s %s", Os.mergePaths(sshMachineInstallDir, CREATE_CERTS_SCRIPT_NAME), host.sensors().get(Attributes.ADDRESS), sshMachineInstallDir)))); if (result != 0) { throw new IllegalStateException("Could not create certificates for docker registry"); } }