Closed JeremyVyska closed 1 year ago
Well, the DockerCreate creates an image, so we an only provide a containerid when creating a container: dockerstart.
It seems like you need to start your container first, and then do the docker network connect
?
- task: ALOpsDockerCreate@1
displayName: 'ALOPS - Create Docker Image' # It will reuse the image if already exists, or build one if it doesn't.
inputs:
memory: '8G'
artifactversion: 20.0.x.x # BC/NAV Version, eg: 9, 10.4, NAV2016, 16.4.24524. $(artifactversion)
artifacttype: OnPrem # Set Artifact Type. $(artifacttype)
artifactcountry: xx # The Country for the Artifact. $(artifactcountry)
versionselect: closest # The version to be selected from the Artifacts. $(versionselect)
- task: ALOpsDockerStart@1
displayName: 'ALOPS - Start Docker Container' # No need to provide any details - it will get the details from previous step
inputs:
memory_gb: '8'
docker_parameters: '--isolation=hyperv'
sql_server: 'some_server' # External SQL Server. $(sql_server)
sql_database: 'client_database' # External SQL Database. $(sql_database)
sql_database_user: 'docker' # External SQL Database User. $(sql_database_user)
sql_database_user_password: '$(bvsqlpassword)'
- task: ALOpsInfo@1
# Give this docker access to the internal network
- task: CmdLine@2
inputs:
script: 'docker network connect --ip 192.168.10.___ office %ContainerID%'
env:
ContainerID: $(ALOPS_DOCKER_CONTAINER_ID)
Also - you would be able to try to use docker_parameters
in the dockercreate, like adding "--net connect --ip 192.168.10.___ ". By using docker-parameters, we add these things automatically with the docker run... .
Ahh, ok. Even with my familiarity with ALOps, somewhere I missed that "CreateDocker" is building the image, "StartDocker" is firing up a Container from that Image.
I'll give the docker_parameters
a go today. That sounds like just what I need.
@JeremyVyska , did this work for you?
@JeremyVyska - did this work for you?
Yuppers. Took ages to get back around to it, but it did.
Heya! I'm trying to set up a pipeline for a complex database driven scenario with an External-to-Docker SQL database, but it's not on the Docker HOST machine.
I can manually spin up a docker and connect it successfully, and I finally realized the problem - I have a network issue. Namely, I need to add the new container to a different docker network.
I can do this with CmdLine@2 easily enough, but the problem was the discovery: $(ALOPS_DOCKER_CONTAINER_ID) is set at the successful conclusion of the the ALOpsDockerStart@1 - which in my case, it won't start, as it's not on the network needed (calls to SQL will get "Host not found").
Is there a reason the container ID setting couldn't be done in the DockerCreate step?
Pardon the messy sample YAML:
Because the variable isn't set yet, it's treated as a literal: