I’m trying to deploy Django on AWS EC2 with AzureDevops pipeline. I have a ssh task to run docker container and I would like to set environment variables. I have tried various commands, but I can’t get it.
Here’s the task:
- task: SSH@0
displayName: Restart Docker Container
inputs:
sshEndpoint: "TMC AWS EC2 Stage Authentication"
runOptions: "inline"
inline: |
echo $(DEBUG)
echo $(export DEBUG=$(DEBUG))
...
sudo docker stop $(containerName)
sudo docker rm $(containerName)
sudo docker run -d -p 80:8000 --name $(containerName) $(AWS_ECR_REPOSITORY_NAME)/${{ parameters.imageName }}:${{ parameters.environment }}-latest
2
Answers
I have solved passing environment variables file to docker run command.
According to the documentation you can pass arguments if you use ‘script’ as your runOptions.