Entorno para desarrollo con PySpark usando docker (imagen de bitcami).
Para poner a funcionar el entorno simplemente es necesario iniciarlo con:
docker-compose up -d
Una vez hemos iniciado los contenedores es necesario esperar unos segundos ya que tarda unos instantes en instalar e iniciar el servidor de jupyter.
Por defecto el servidor estará funcionando en el localhost
pero en caso de querer usar la ip podemos obtenerla con el siguiente comando:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' docker-spark-master-1
Web
VSCode
Para apagarlo:
docker-compose down
El entorno por defecto consta de 2 workers
y 1 master
.
Desde el archivo docker-compose el master
ejecuta el script docker-start, este lo que hace es:
pyspark
y notebook
.Importante El servidor de Jupyter se inicia de manera que no requiere de contraseña y admite conexiones desde cualquier lado, no es recomendable mantener esta configuración en la mayoría de los casos.
jupyter-lab --ip=0.0.0.0 --port 8888 --no-browser --notebook-dir=/proyecto --NotebookApp.allow_origin="*" --allow-root --ServerApp.password='' --ServerApp.token='' --ServerApp.password_required=False
En caso de usar linux es posible que el contenedor master
devuelva un error, en ese caso es posible que sea necesario hacer lo siguiente antes de iniciar el entorno:
chmod +x docker-start.sh
Environment for PySpark development using docker (bitcami image).
To get the environment working, you just need to start it with:
docker-compose up -d
Once we have started the containers, we need to wait a few seconds for the jupyter server to install and start.
By default the server will run on localhost
but if you want to use the ip it's possible to get it with:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' docker-spark-master-1
Web
VSCode
To shutdown:
docker-compose down
By default, the environment has 2 workers' and 1
master'.
From the docker-compose file the master
runs the docker-start script, which that script does the following:
pyspark
and notebook
libraries.Important The Jupyter server is started in a way that doesn't require a password and allows connections from anywhere, which is not recommended for most uses.
jupyter-lab --ip=0.0.0.0 --port 8888 --no-browser --notebook-dir=/proyecto --NotebookApp.allow_origin="*" --allow-root --ServerApp.password='' --ServerApp.token='' --ServerApp.password_required=False
In case of using linux it is possible that the master
container returns an error, in that case it may be necessary to do the following before starting the environment:
chmod +x docker-start.sh