DEV Community

Discussion on: Why Every Developer should Learn Docker in 2024

Collapse
 
jefflindholm profile image
Jeff Lindholm

If you use powershell the following in your profile file, will create an alias for you.
dev-here (language) "ruby, node, dotnet, etc" will get the latest container start it and put yuou in a shell with your current directory mounted to 'code' with port 8000 open by default. Working on the python piece still

function dev-here($lang, $port = 8000) {
if ($lang -eq '') {
echo 'usage is dev-here '
return
}
$args = 'bash'
if ($lang -eq 'python') {
$args = "bash"
# $args = "bash -c 'cd code && pip install -r requirements.txt && bash'"
}
$msg = $lang + ' opening port ' + $port + ' running ' + $args
echo $msg
echo "docker run --rm -it -e USER=dev -p ${port}:${port} -v ${PWD}:/code --network="host" $lang $args"
docker run --rm -it -e USER=dev -p ${port}:${port} -v ${PWD}:/code --network="host" $lang $args
}