Primi passi con Docker e Prestashop 1.7
Ieri è stata la giornata del Prestashop day a Milano, un evento di cui parlerò meglio in un altro post. Quello di cui voglio parlarti oggi è come ho cominciato a smanettare con Docker.
Prestashop 1.7 è da qualche giorno in RC e ho pensato di dedicarmici un attimo per comprenderne le novità di cui ho sentito parlare e magari iniziare a produrci qualcosa.
Per scaricare questa nuova versione sono andato sulla pagina dedicata ai download delle versioni per sviluppatori e mi sono incuriosito dal prominente link con la balena che campeggia ad altezza occhio.
Ho visto e sentito grandi cose su Azure, ma per ora concentriamoci su Docker.
Cliccando il link si viene rimandati alla pagina dell’immagine da scaricare e viene proposto un comodissimo comando docker pull prestashop/prestashop
da eseguire da terminale.
“Ammazza che semplicità” ho pensato, e ho capito che era giunto il momento di dare una opportunità a Docker.
Scaricato e installato il dmg, l’ho eseguito, e un balenottero si è aggiunto alle altre icone nella tray del mac. Al primo avvio un popup incita a prendere familiarità coi comandi di docker, e per comododità te li riporto tutti qui:
⇒ docker help Usage: docker [OPTIONS] COMMAND [arg...] docker [ --help | -v | --version ] A self-sufficient runtime for containers. Options: --config=~/.docker Location of client config files -D, --debug Enable debug mode -H, --host=[] Daemon socket(s) to connect to -h, --help Print usage -l, --log-level=info Set the logging level --tls Use TLS; implied by --tlsverify --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA --tlscert=~/.docker/cert.pem Path to TLS certificate file --tlskey=~/.docker/key.pem Path to TLS key file --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Commands: attach Attach to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on a container, image or task kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry. logout Log out from a Docker registry. logs Fetch the logs of a container network Manage Docker networks node Manage Docker Swarm nodes pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart a container rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images service Manage Docker services start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers swarm Manage Docker Swarm tag Tag an image into a repository top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information volume Manage Docker volumes wait Block until a container stops, then print its exit code
Per ognuno di questi comandi è poi disponibile un help dedicato, ad esempio docker help run
ci fornirà indicazioni sulle opzioni disponibili per il comando docker run
.
Le opzioni messe a disposizione dal team Prestsahop per configurare il container sono molte, elencate in fondo alla pagina, e per utilizzarle, vanno incluse nel comando di run in uno dei due modi seguenti, dove il primo elenca le variabili di ambiente e i loro valori runtime con l’opzione -e
mentre il secondo consente di utilizzare un comodo file .env
che va creatoa parte
⇒ docker run -ti --name prestashop-test -p 8080:80 -d -e "PS_COUNTRY='it'" prestashop/prestashop
⇒ docker run -ti --name prestashop-test -p 8080:80 -d --env-file ".env" prestashop/prestashop
Esempio di file .env
PS_LANGUAGE="it" PS_COUNTRY="it"
Ma attenzione, perchè una volta fatto partire il container, e avviata l’installazione ti ritroverai con un problemuccio (che a dire il vero è segnalato come important note)
Non c’è il server MySQL!!1! (continua)